Wednesday, 19 March 2014

Creation of Infoset with Sort and deletion adjacent duplicates Functionality - Part 1

Creation of Info-Set:
Initial screen by using the transaction code /nSQ02

Provide a name for your Info Set. (For purposes of this example, I'm naming Z_Sales_docu_data.) Then click the Create button.
 
 Name as ‘Sales Document Demo’... (Demo)
Select radio button Table join using basis table and provide input as VBAK.
Click on Continue button.
 
 Now you can see that table is in the graphical format .To add more tables, you can use Button or Edit/Insert Table menu options.
Give table name and Enter.
 Once you select enter button new table will appear .If table links are not available ,then you have to manually link those using drag and drop methods.
After that below screen gets displayed.
 You can check the table using button . If table join is correct you’ll get Defined join conditions are correct message.

 Select  option.

Select the Create empty field group option.

 
 In your left hand pane all tables that you select will appear .In your right hand side you can see the field groups.
 Add fields which are relevant to the report.
Assign fields to the field groups (shown on the top right of the screen) within the Info-Set by Drag and dropping the fields from left hand pane to right hand pane of Field groups. These field groups will display in the SAP Query tool during reporting. Only the fields that you include in your field groups will be available for field selection in the SAP Query tool that uses this Info-Set as its data source. By default, these field groups are empty.
Once you add all the required fields, it looks like this.
 Then click on button to add additional code .Following screen will appear.
 
 Click on Code Icon (Shift+F8) displayed on application bar, you will be getting lists events in 'Code section'.
 
 
 In Data Section, declare an internal table like below code
FIELD-SYMBOLS <fs_dtab> TYPE STANDARD TABLE.
DATAsort_f1 TYPE fieldname,
      sort_f2 
TYPE fieldname,
      sort_f3 
TYPE fieldname.
In INITIALIZATION Event write the following code.
sort_f1 'VBAK-VBELN'.
sort_f2 
'VBAK-ERDAT'.
sort_f3 
'VBAK-ERZET'.
In END-OF-SELECTION (after list) Event write the following code.
ASSIGN ('%G00[]'TO <fs_dtab>.
IF <fs_dtab> IS ASSIGNED.
  
SORT <fs_dtab> BY (sort_f1) (sort_f2) (sort_f3)
                 
ASCENDING.
  
DELETE ADJACENT DUPLICATES FROM <fs_dtab> COMPARING
                                  
(sort_f1).
ENDIF.
 Generate the Info-Set by clicking the Generate button   (the red beach ball) on the Application toolbar. A message appears in the status bar, saying that the Info-Set was generated.

Creation of Infoset is Done!!!
:)

2 comments:

  1. May I please have the screenshot of above mentioned script because I am still getting an error SORT F1 already declared.

    Regards
    Arjun

    ReplyDelete
  2. Would any help me for concatenate two field data in one new field.

    ReplyDelete