5 1 1 1 1 1 Rating 100% (9 Votes)
Many people still asks how to create field catalog for CL_GUI_ALV_GRID or REUSE_ALV_GRID_DISPLAY on a base of internal table. This is very easy since we have SALV classes, you could see it in my article Create XLSX/MHTML file from internal table in background and probably also somewhere in the net. To make it easier here are ready methods to create LVC and SLIS field catalogs from internal table using CL_SALV_CONTROLLER_METADATA and  CL_SALV_TABLE. Both methods are created with new ABAP 7.40 SP05 syntax.
LVC Field catalog definition

  class-methods lvc_fcat_from_internal_table
    it_table type any table
  returning value(rt_fcattype lvc_t_fcat.

LVC field catalog implementation

  method lvc_fcat_from_internal_table.
    datatable type ref to data.
    create data table like it_table.
    assign table->to field-symbol(<table>).
                                  r_salv_table   data(salv_table)
                                  t_table        <table>  ).
        rt_fcat cl_salv_controller_metadata=>get_lvc_fieldcatalog(
            r_columns      salv_table->get_columns" ALV Filter
            r_aggregations salv_table->get_aggregations" ALV Aggregations
      catch cx_root.

Read more ...

1 1 1 1 1 Rating 0% (0 Votes)
I was playing a bit with CL_GUI_TIMER some time ago and I thought that this would be good to use it somewhere to have idea how it works. So I've created then a small game Battleships, which you for sure know from analog version. 

Game is very simple, firstly you have to build your own map with ships. Just to remind you, there are 2 submarines, 2 destroyers, 1 cruiser, 1 battleship and 1 aircraft carrier. Map is created with CL_GUI_ALV_GRID. Once you click on status button to add one of the ships, map will show you in which place you can start ship. When you'll select position of the start it will show you possible fields for end.
After you build your map hit Join Game button and wait for second player to join you. 
Read more ...

1 1 1 1 1 Rating 0% (0 Votes)
If you imported NUGG file from previous article you could be surprised that there is one additional FM available called Z_AB_POPUP_GRID_MULTI_SEL. This FM can be used to call a popup with ALV grid which allows multiple row selects. 
1) In order to prepare such popup you'll need to firstly define some global variables in FG which you can find bellow:

constantsc_ccname_grid_popup type scrfname value 'CC_GRID_POPUP'.
datago_popup_custom_cont      type ref to cl_gui_custom_container.
datago_popup_grid             type ref to cl_gui_alv_grid.
datags_popup_layout           type lvc_s_layo.
datags_popup_variant          type disvariant.
datagt_popup_fcat             type lvc_t_fcat.
datag_popup_question          type char70.
field-symbols<gt_popup_outtab> type standard table.

2) Then you need to create GUI status with Cancel and Enter Buttons
Read more ...

5 1 1 1 1 1 Rating 100% (6 Votes)
This topic was raised many times, I always found it's not possible to (or at least to hard to try) to update components allocation for routing operations. Fortunately I had to do it somehow and I manage to do it in two ways : 
1) with BDC (yeah I know, creepy but possible)
2) using EWB FM's basing on the SAP note 488765 - "Do it yourself EWB programming".
Today I will present program which is using EWB, in future I will post an example of doing this by BDC.
This program reads data from Excel file with proper structure (you can find Excel template in attachment). After reading data it collects all routings which needs to be updated to be sure that each routing is updated only once. Then the most important part is done in following way:
1) We need to load each routing and connected BOM to memory with CP_CC_S_LOAD_COMPLEX_BY_TSK and CP_CC_S_LOAD_COMPLEX_BY_BOM,
2) Next step is to get the BOM into internal table using CP_CC_S_PROVIDE_ITM_BY_AS_PATH.  BOM table contains also a explosion of sub-assemblies which are not phantoms which at the beginning seem to be useless, but after a while you'll notice that we need all levels of multilevel BOM in order to calculate Path (PLMZ-KANTE) and order level (PLMZ-STLST).  If you have to do components allocation for single level BOM then reworking the table is not needed, but in my example I did it as I needed to allocate components from multi-level BOM. You'll find here a form ITEM_CHECK which do the manipulation of the table. 
3) After it's done we need load operation data (CP_CC_S_PROVIDE_COM_BY_OPR) and current allocation of components (CP_CL_P_OPR_ALLOCATION_PROVIDE). We need to do it in order to delete current allocation.
4) Deletion is done with CM_CL_P_COM_DELETE and saved with CP_CC_S_SAVE. Deletion is committed as in other case there is no possibility to create new allocation.
5) Allocation is deleted, so we can now recreate it with new values. Firstly we need to reload again operation data to memory with CP_CC_S_OPR_PROVIDE_BY_MTK and then create allocation with  CP_CC_S_CREATE_COM. Again we need to save allocation with CP_CC_S_SAVE.
Bellow you'll find the code of the program. You can download also NUGG file for it!.
Program works in two steps, firstly it displays reading log, if it is ok you have to press first button on the toolbar  to create allocation.
Read more ...

5 1 1 1 1 1 Rating 100% (1 Vote)
As promised today I'll put code for a method to reset the rejection of the Purchase requisition. Most of the code is the same like in the check method, in fact even the code is repeated again so you can use this one without checking if reset of rejection can be done or not.

I_BANFN TYPE EBAN-BANFN -> Purchase Requistion number


C_FACTORY TYPE REF TO IF_PURCHASE_REQ_FACTORY -> Purchase requisition factory


E_RESET TYPE FLAG -> Reset was successful



Read more ...

1 1 1 1 1 Rating 0% (0 Votes)
In the previous article I've shown how to check if we can reset the rejection of the purchase requisition. In the same way you can check if rejection is allowed or if release is allowed or if reset of release is allowed. To do that you'll have to replace  following piece of code from previous example fo_releasable->is_reset_rej_allowed( )
 with one of the following:
  • fo_releasable->is_rejection_allowed( ) 
  • fo_releasable->is_release_allowed( )
  • fo_releasable->is_reset_rel_allowed( ) 
In next article I will show you how to reset the rejection of PR .
Add a comment

1 1 1 1 1 Rating 0% (0 Votes)
Working with Purchase Requisitions in ABAP is quite pleasant job, but sometimes it's not so easy like with other documents types. You cannot easily say if Requisition is rejected and can be reset by checking EBAN table. You have to use OO PR objects to be able to do so. Bellow you can find a method how to check if you can reset the rejection of the requisition done in the WF. 

I_BANFN TYPE EBAN-BANFN ->Purchase Requisition Number


E_RESETABLE TYPE FLAG -> If rejection can be reset this parameter will be set to 'X'


CO_FACTORY TYPE REF TO IF_PURCHASE_REQ_FACTORY -> Purchase requisition factory



Read more ...

1 1 1 1 1 Rating 0% (0 Votes)
We got all needed functions, so I'll give you an example how to call the methods correctly to get characteristics update window like this:
Program bellow is reading firstly the info about stored values in given characteristic and then throws an update screen. After exiting from the screen it's saving data to database.
Add a comment
Read more ...