Wednesday, August 11, 2010

ALV Tree Demo using RS_TREE_LIST_DISPLAY and RS_TREE_CONSTRUCT (Six levels)

*&--------------------------------------------------------------*
*& Report Z_Simpletree *
*& Author : Swarna.S. *
*& Published at SAPTechnical.COM
*&--------------------------------------------------------------*
*& AS : Simple tree report using RS_TREE_CONSTRUCT *
*& and RS_TREE_LIST_DISPLAY upto 6 levels *
*&-------------------------------------------------------------*
REPORT  z_simpletree.
* type pool declarations for tree
TYPE-POOLS : fibs,stree.
*Data declaration for additional node information
DATA : t_node TYPE snodetext.
*Internal table and wa decl for nodes
DATA : it_node LIKE TABLE OF t_node INITIAL SIZE 0,
wa_node LIKE t_node.
*Internal table and wa decl for Education table PA0022
DATA : it_0022 TYPE STANDARD TABLE OF pa0022 INITIAL SIZE 0,
wa_0022 TYPE pa0022.
*Internal table and wa decl for text table t517x
DATA : it_517x TYPE STANDARD TABLE OF t517x INITIAL SIZE 0,
wa_517x TYPE t517x.
*Internal table and wa decl for text table t517T
DATA : it_517t TYPE STANDARD TABLE OF t517t INITIAL SIZE 0,
wa_517t TYPE t517t.
*Internal table and wa decl for text table t519T
DATA : it_519t TYPE STANDARD TABLE OF t519t INITIAL SIZE 0,
wa_519t TYPE t519t.
*initialization event
INITIALIZATION.
*Start of selection  event
START-OF-SELECTION.
*Select the data for tree
PERFORM fetch_data.
*Build the hierarchy for tree
PERFORM build_hierarchy.
*Build Tree for display
PERFORM build_tree.
*&--------------------------------------------------------------*
*& Form fetch_data
*&--------------------------------------------------------------*
* text
*---------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*---------------------------------------------------------------*
FORM fetch_data .
*select data from PA0022
SELECT * FROM pa0022 INTO CORRESPONDING FIELDS OF TABLE it_0022
UP TO 50 ROWS.
*select data from T517x
SELECT * FROM t517x INTO CORRESPONDING FIELDS OF TABLE it_517x
WHERE langu = 'E'.
*select data from T517T
SELECT * FROM t517t INTO CORRESPONDING FIELDS OF TABLE it_517t
WHERE sprsl = 'E'.
*select data from T519t
SELECT * FROM t519t INTO CORRESPONDING FIELDS OF TABLE it_519t
WHERE sprsl = 'E'.
ENDFORM.                    " fetch_data
*&----------------------------------------------------------------*
*& Form build_hierarchy
*&----------------------------------------------------------------*
* text
*----------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------*
FORM build_hierarchy .
*Building the nodes and hierarchy for tree
CLEAR : it_node[], wa_node.
  wa_node-type = 'T'.
wa_node-name = 'Education'.
wa_node-tlevel = '01'.
wa_node-nlength = '15'.
wa_node-color = '4'.
wa_node-text = 'Infotype 0022'.
wa_node-tlength ='20'.
wa_node-tcolor = 3.
APPEND wa_node TO it_node.
CLEAR wa_node.
*Filling the values of internal table into tree
LOOP AT it_0022 INTO wa_0022.
    wa_node-type = 'P'.
wa_node-name = 'PERNR'.
wa_node-tlevel = '02'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = wa_0022-pernr.
wa_node-tlength ='20'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.
*Filling the text of T517t
READ TABLE it_517t INTO wa_517t WITH KEY slart = wa_0022-slart.
    wa_node-type = 'P'.
wa_node-name = wa_0022-slart.
wa_node-tlevel = '03'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = wa_517t-stext.
wa_node-tlength ='40'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.
*Filling the text of T519t
READ TABLE it_519t INTO wa_519t WITH KEY slabs = wa_0022-slabs.
    wa_node-type = 'P'.
wa_node-name = wa_0022-slabs.
wa_node-tlevel = '04'.
wa_node-nlength = '8'.
wa_node-color = '2'.
wa_node-text = wa_519t-stext.
wa_node-tlength ='40'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.
*Filling the text of T517x
READ TABLE it_517x INTO wa_517x WITH KEY faart = wa_0022-sltp1.
wa_node-type = 'P'.
wa_node-name = wa_0022-sltp1.
wa_node-tlevel = '05'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = wa_517x-ftext.
wa_node-tlength ='40'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.
    wa_node-type = 'P'.
wa_node-name = wa_0022-zzper.
wa_node-tlevel = '06'.
wa_node-nlength = '8'.
wa_node-color = '1'.
wa_node-text = '% Completed'.
wa_node-tlength ='15'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.
  ENDLOOP.
ENDFORM.                    " build_hierarchy
*&---------------------------------------------------------------*
*& Form build_tree
*&---------------------------------------------------------------*
* text
*----------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------*
FORM build_tree .
*Fm for constructing the tree
CALL FUNCTION 'RS_TREE_CONSTRUCT'
TABLES
nodetab = it_node.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*FM for displaying the tree
CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
callback_program = sy-repid
check_duplicate_name = '1'
color_of_node = '4'
color_of_mark = '3'
color_of_link = '1'
color_of_match = '5'
node_length = 30
text_length = 75
use_control = 'L'.
ENDFORM.                    " build_tree

Output

DC recording from testing client to development client

This method would be useful, when you don’t have required datum in development client and when you have same in testing client and you want to BDC recording with that datum.

Login to the Testing client where you will have data.

Go to transaction SHDB and press new recording.

As an instance, here we will try to modify vendor’s postal code of his address. So, give FK02 as the transaction code to be executed and give recording name like ‘ZRECORD’.

Now it goes to Vendor master update screen. Opt a vendor and click the address checkbox and press enter.

It will show the vendor’s address information.

Now change the existing PIN code 700019 to 560076 and press save. It will take you to the recording screen.

Now you cannot create a program with this recording information in testing client. So, import your recording information to one presentation server file. Press import button.

Give a text file name and save it in the presentation server.



BDC recording from testing client to development client

...Previous

Then Go to SHDB transaction in development client and go to new recording. Give the recording name as ZRECORDINGNEW and opt the same vendor master updation transaction code FK02.

In this case your development client should have at least one vendor. If not create it and input the vendor in FK02 transaction and as you did earlier select the address checkbox.

It will show you the address information. You don’t change anything in that and come back. Because this is not the vendor to whom we are going to change his PIN Code.

Now it will show you the recording information. Delete all the recording information and press the import button and browse bdc_recording file from the presentation server.

The previous recording information will loaded in to BDC recording and go back from the screen. It would popup for saving the recording. Now save that recording.

Select the recording and press ‘program’ button. It will popup for new program creation. Input the required details and the expected BDC recording program will get created.

report ZVENDORUPDATE
no standard page heading line-size 255.

include bdcrecx1.

start-
of-selection.

perform open_group.

perform bdc_dynpro using 'SAPMF02K' '0106'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-LIFNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-LIFNR'
'B002568'.
perform bdc_field using 'RF02K-D0110'
'X'.
perform bdc_dynpro using 'SAPMF02K' '0110'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-PSTLZ'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_field using 'LFA1-NAME1'
'MURARI SHARAN SRIVASTAVA'.
perform bdc_field using 'LFA1-SORTL'
'000568'.
perform bdc_field using 'LFA1-STRAS'
'Brook House, Shakespeare Sarani'.
perform bdc_field using 'LFA1-ORT01'
'Kolkatta'.
perform bdc_field using 'LFA1-PSTLZ'
'560076'.
perform bdc_field using 'LFA1-LAND1'
'IN'.
perform bdc_field using 'LFA1-REGIO'
'25'.
perform bdc_field using 'LFA1-SPRAS'
'EN'.
perform bdc_transaction using 'FK02'.

perform close_group.

Working with Screen Painter

SCREEN PAINTER:-

Screen painter is a tool in ABAP dev workbench used to create the screens using the

T-code SE51. In the screen painter, you can define the following interface elements with their associated attributes.
1. Input/Output Fields
2. Field Names
3. Checkboxes
4. Radio Buttons
5. Group Boxes
6. Sub screens.
7. Pushbuttons with No Fixed Position

and others

STEP-BY-STEP DEMO FOR SCREEN PAINTER.

Create a Z program in SE38.

Click on Save. We will write the code later in this.

Go to transaction SE51.

Enter the created program name and screen number.

Enter the short description and click on save.

Click on flowlogic tab.

Uncomment the statement “ MODULE STATUS_0100 “.

Double click the “ status_0100.”

The below screen will be displayed,

Click on yes.

Following pop-up screen appears. Select the “zdemo_screen_painter” “main program” and click on continue.

Click on yes.

Screen would be displayed as follows:

Now come back to the transaction SE51. Select flow logic. Click in layout.

Screen painter window will be displayed like this. Here we will design the required screen fields.

Click on the middle icon dictionary / program fields window. Or F6.

Following screen appears:

Enter the table name in the table field name.

Click on get from dictionary.

Select the required fields from MARA table from dictionary. Click on OK or continue.

After placing the required fields, you can view the below screen.

Create the push button from the toolbox.

Select the pushbutton, drag and drop the button onto the screen.

Create the other required buttons in the same procedure mentioned above and assign the name, text, and function code for each one.

After creating the screen click on save check and activate.

press flow logic button. .

Click on tab Element List enter OK_CODE.

Paste the below Code in created z program created earlier:

*&-------------------------------------------------------------------*
*& Report ZDEMO_SCREEN_PAINTER
*&
*&-------------------------------------------------------------------*
*& Demo for Screen Painter.
*& By Vikramchellappa.
*&-------------------------------------------------------------------*
REPORT  ZDEMO_SCREEN_PAINTER.
******************************************************************
* TABLE DECLARATIONS.
******************************************************************
  TABLES: MARA.
******************************************************************
* DATA DECLARATIONS.
*****************************************************************
DATA:  MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
MTART TYPE MARA-MTART,
MATKL TYPE MARA-MATKL,
DISPLAY TYPE C,
SAVE TYPE C,
DELETE TYPE C,
CLEAR TYPE C,
EXIT TYPE C,
OK_CODE LIKE SY-UCOMM.
*****************************************************************
* CALLING SCREEN.
*****************************************************************
CALL SCREEN 100.
*&--------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&--------------------------------------------------------------*
* text
*--------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
*  SET PF-STATUS 'ZMENU'.
* SET TITLEBAR 'ZMENU_PAINTER'.
CASE SY-UCOMM.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'DISPLAY'.
SELECT SINGLE ERSDA ERNAM MTART MATKL FROM MARA
INTO (MARA-ERSDA, MARA-ERNAM, MARA-MTART, MARA-MATKL)
WHERE MATNR = MARA-MATNR.
    WHEN 'CLEAR'.
CLEAR MARA.
ENDCASE.
ENDMODULE. " STATUS_0100 OUTPUT

Output:-

Enter Material number On Material Field. Click on Display.

Material Information is displayed as shown below:


how to assign a TCODE for your report..!

yes you can assign a TCODE for your report
go to SE93 and give any tcode name starting with Z
cpress CREATE button.
it will take you to another screen where you need to select program and selection screen, fill in all the other rquired entries.
you will be able to create the TCODE.

take care of the selection while selecting like "program and selection screen" not "program and screens"

Dynamic Selection Screen

Following is the code in which the selection screen changes based on the user's click on the radio buttons. The entire selection screen is changed. The F8 button is disabled and selection screen push-button which changes dynamically based on radio button and does the functionality of the F8 button.

*&----------------------------------------------------------------*
*& Report Z_sscr *
* Published at SAPTechnical.COM
*& *
*&----------------------------------------------------------------*
*&DYNAMIC Selection screen based on user clicks on the radiobutton*
*& *
*&----------------------------------------------------------------*
REPORT  zsscr.
*TYPE POOLS DECLARATIONS FOR VALUE REQUEST MANAGER AND ICONS
TYPE-POOLS : vrm,
icon.
*SELECTION SCREEN FIELDS
TABLES : sscrfields.
*GLOBAL DECLARATIONS
DATA : flag TYPE c,
tablename(10),
mmtable LIKE dd02l-tabname,
sdtable LIKE dd02l-tabname,
hrtable LIKE dd02l-tabname.
*DECLARATIONS FOR SELECTION SCREEN STATUS
DATA it_ucomm TYPE TABLE OF sy-ucomm.
***********SELECTION-SCREENS**********************
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME.
*FOR DYNAMIC DISPLAY OF MODULES
PARAMETERS : pa RADIOBUTTON GROUP rad USER-COMMAND com MODIF ID mod,
pb RADIOBUTTON GROUP rad MODIF ID rad,
pc RADIOBUTTON GROUP rad MODIF ID cad.
SELECTION-SCREEN SKIP.
**TO INCLUDE DYNAMIC ICONS
SELECTION-SCREEN COMMENT 2(6) text_001.
*DYNAMIC LIST BOX BASED ON USER SELECTIONS
PARAMETERS one AS LISTBOX VISIBLE LENGTH 20 MODIF ID mod.
PARAMETERS two AS LISTBOX VISIBLE LENGTH 20 MODIF ID rad.
PARAMETERS three AS LISTBOX VISIBLE LENGTH 20 MODIF ID cad.
SELECTION-SCREEN END OF BLOCK blk1.
*DISPLAY DYNAMIC PUSHBUTTON ON APP TOOLBAR ON USER CLICKS
SELECTION-SCREEN: FUNCTION KEY 1,
FUNCTION KEY 2,
FUNCTION KEY 3.
**EVENT ON SELECTION SCREEN FOR OUTPUT DISPLAY
AT SELECTION-SCREEN OUTPUT.
*CLICK OF FIRST RADIO BUTTON
IF pa = 'X'.
sscrfields-functxt_01 = 'Materials Management'.
WRITE icon_plant AS ICON TO text_001.
*CODE TO GET DYNAMICS BASED ON THE SELECTED RADIO
LOOP AT SCREEN.
IF screen-group1 = 'MOD'.
screen-intensified = '1'.
screen-active = 1.
screen-display_3d = '1'.
MODIFY SCREEN.
ENDIF.
IF screen-group1 = 'RAD'.
screen-intensified = '0'.
screen-active = 0.
screen-display_3d = '0'.
MODIFY SCREEN.
ENDIF.
IF screen-group1 = 'CAD'.
screen-intensified = '0'.
screen-active = 0.
screen-display_3d = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
*CLICK OF SECOND RADIO
IF pb = 'X'.
sscrfields-functxt_02 = 'Sales And Distribution'.
WRITE icon_ws_ship AS ICON TO text_001.
LOOP AT SCREEN.
IF screen-group1 = 'RAD'.
screen-intensified = '1'.
screen-active = 1.
screen-display_3d = '1'.
MODIFY SCREEN.
ENDIF.
IF screen-group1 = 'MOD'.
screen-intensified = '0'.
screen-active = 0.
screen-display_3d = '0'.
MODIFY SCREEN.
ENDIF.
IF screen-group1 = 'CAD'.
screen-intensified = '0'.
screen-active = 0.
screen-display_3d = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
*CLICK OF THIRD RADIO
IF pc = 'X'.
sscrfields-functxt_03 = 'Human Resources'.
WRITE icon_new_employee AS ICON TO text_001.
LOOP AT SCREEN.
IF screen-group1 = 'RAD'.
screen-intensified = '0'.
screen-active = 0.
screen-display_3d = '0'.
MODIFY SCREEN.
ENDIF.
IF screen-group1 = 'MOD'.
screen-intensified = '0'.
screen-active = 0.
screen-display_3d = '0'.
MODIFY SCREEN.
ENDIF.
IF screen-group1 = 'CAD'.
screen-intensified = '1'.
screen-active = 1.
screen-display_3d = '1'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
*CUSTOMISING THE TOOLBARS OF THE SELECTION SCREEN
*WITH F8 BUTTON DISABLED
  APPEND :  'PRIN' TO it_ucomm,
'SPOS' TO it_ucomm,
'ONLI' TO it_ucomm.
  CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
EXPORTING
p_status = sy-pfkey
TABLES
p_exclude = it_ucomm.
**EVENT ON THE SELECTION
AT SELECTION-SCREEN.
* LIST BOX ONE VALUES
CASE one.
WHEN '1'.
mmtable = 'MARC'.
WHEN '2'.
mmtable = 'MARA'.
WHEN '3'.
mmtable = 'MARD'.
WHEN '4'.
mmtable = 'MARM'.
ENDCASE.
* LIST BOX TWO VALUES
CASE two.
WHEN '1'.
sdtable = 'VBAK'.
WHEN '2'.
sdtable = 'VBAP'.
WHEN '3'.
sdtable = 'VBUK'.
WHEN '4'.
sdtable = 'VBUP'.
ENDCASE.
* LIST BOX THREE VALUES
CASE three.
WHEN '1'.
hrtable = 'PA0001'.
WHEN '2'.
hrtable = 'PA0006'.
WHEN '3'.
hrtable = 'PA0022'.
WHEN '4'.
hrtable = 'PA0008'.
ENDCASE.
*VALUES FOR CLICK OF THE PUSHBUTTON ON APP TOOLBAR
*AND ENABLING THE BUTTONS TO PERFORM F8
CASE sscrfields-ucomm.
WHEN 'FC01'.
tablename = mmtable.
sscrfields-ucomm = 'ONLI'.
WHEN 'FC02'.
tablename = sdtable.
sscrfields-ucomm = 'ONLI'.
WHEN 'FC03'.
tablename = hrtable.
sscrfields-ucomm = 'ONLI'.
ENDCASE.
*INITIALIZATION EVENT
INITIALIZATION.
*VALUES ASSIGNED TO DROPDOWNLISTS IN THE SUBROUTINES
PERFORM f4_value_request_pa.
PERFORM f4_value_request_pb.
PERFORM f4_value_request_pc.
*START OF SELECTION EVENT
START-OF-SELECTION.
*SUBROUTINE FOR OUTPUT
PERFORM output.
*&----------------------------------------------------------------*
*& Form f4_value_request_PA
*&----------------------------------------------------------------*
* text
*-----------------------------------------------------------------*
*SUBROUTINE TO PROVIDE DROPDOWN VALUES TO LIST1
FORM f4_value_request_pa.
  DATA: l_name TYPE vrm_id,
li_list TYPE vrm_values,
l_value LIKE LINE OF li_list.
  l_value-key = '1'.
l_value-text = 'Plant Data for Material'.
APPEND l_value TO li_list.
CLEAR l_value.
  l_value-key = '2'.
l_value-text = 'General Material Data'.
APPEND l_value TO li_list.
CLEAR l_value.
  l_value-key = '3'.
l_value-text = 'Storage Location Data for Material'.
APPEND l_value TO li_list.
CLEAR l_value.
  l_value-key = '4'.
l_value-text = 'Units of Measure for Material'.
APPEND l_value TO li_list.
CLEAR l_value.
  l_name = 'ONE'.
  CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = l_name
values = li_list
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " f4_value_request_tabname
*&----------------------------------------------------------------*
*& Form f4_value_request_PB
*&----------------------------------------------------------------*
* text
*-----------------------------------------------------------------*
*SUBROUTINE TO PROVIDE DROPDOWN VALUES TO LIST2
FORM f4_value_request_pb.
  DATA: l_name TYPE vrm_id,
li_list TYPE vrm_values,
l_value LIKE LINE OF li_list.
  l_value-key = '1'.
l_value-text = 'Sales Document: Header Data'.
APPEND l_value TO li_list.
CLEAR l_value.
  l_value-key = '2'.
l_value-text = 'Sales Document: Item Data'.
APPEND l_value TO li_list.
CLEAR l_value.
  l_value-key = '3'.
l_value-text = 'Sales Document:Header Status'.
APPEND l_value TO li_list.
CLEAR l_value.
  l_value-key = '4'.
l_value-text = 'Sales Document: Item Status'.
APPEND l_value TO li_list.
CLEAR l_value.
  l_name = 'TWO'.
  CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = l_name
values = li_list
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " f4_value_request_PB
*&----------------------------------------------------------------*
*& Form f4_value_request_PC
*&------------------

Dynamic Variant in a report

Scenario: This blog is to explain the creation of Dynamic Variant for report selection screen.

Let us understand ‘What is Dynamic Variant?’ Dynamic Variant consists of selection variable for a selection screen item where in a formula can be defined. For example: On the selection screen of a report, take a Date field, which needs to be dynamic. From Date should be ‘Current date – 15’ and To Date should be ‘Current Date’. In this way the report when run with this variant, it would be possible to retrieve all those records which are past 15 days entries from now.

Please find below the procedure to define DYNAMIC Variant.

Step 1: Go to transaction SE38 to specify the Program name and select ‘Variant’ radio button and ‘Display’.

Then it will lead you to next screen ‘ABAP:Variants –Initial Screen’ as shown below: Specify the variant which needs to be created or changed.

Step2: Specify all those values which are static on the selection screen in this step. Then click ‘Variant Attributes’ to define selection variable for ‘Date Created’ on the selection screen.

Step 3: In this step, provide suitable meaning for the variant. As we need to define selection variable for ‘Date created’ item on selection screen, check the box under L as shown in the selection screen below:

Step 4: In the previous step, select ‘Selection Variables’ on the menu. It leads to the next screen as shown below. As we have decided to create selection variable for ‘Date created’ item only, in this screen you get to see the variable as ‘Date created’. Here you are provided with three options.

T: Table variable from TVARV

D: Dynamic Date Calculation

B: User defined Variables.

From the provided options as per our requirement select ‘D’ option. This can be done by clicking the Traffic lights under ‘D’as shown below to know that the particular option is selected.

Now click the black arrow as shown in the screenshot below and you will be prompted with search help of different formulas for the selection variable.

Step 5: Find the suitable formula as ‘Current date – xxx, current date + yyy’ and select it. This will lead you to the next screen to enter the values for xxx and yyy. So, provide values as 15 for xxx and 0 for yyy. Save the variant and this will conclude the creation of dynamic variant with the help of selection variable. This variant can also be used in the background jobs.

Working with Menu Painter

Create a program in SE38 T- Code.

Enter the Title of the Program And Select the Type as Executable Program.

And click on save. Save it in a Relevant Package.

Go to T-code SE41

Enter the Program name and Status name.

Click on create

Enter the Short text for Status.

Click on Menu Bar.

Specify a Menu Name file

Double click on File.

Enter the Code and text Values.

Click on save, check and Activate.

Press Execute or F8.

Click on Continue and Enter.

Created Menu is displayed here.



To create a Title, Click on Title List.

Click on create.

Enter the Title Code and Title. Click on continue.

Click on enter and Click on Test.

Enter the created Title Code in Title, Click on execute.

Click on Continue.

Created Title Displayed.

Click on Save.

*&---------------------------------------------------------------------*
*& Report ZMENU_PAINTER
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT  ZMENU_PAINTER.
TABLES: MARA.
DATA:  MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
DISPLAY TYPE C,
SAVE TYPE C,
DELETE TYPE C,
CLEAR TYPE C,
EXIT TYPE C,
OK_CODE LIKE SY-UCOMM.
CALL SCREEN 101.
*&---------------------------------------------------------------------*
*& Module STATUS_0101 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0101 OUTPUT.
SET PF-STATUS 'ZMENU'.
SET TITLEBAR 'ZMENU_PAINTER'.
CASE SY-UCOMM.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'DISPLAY'.
SELECT SINGLE ERSDA ERNAM FROM MARA INTO (MARA-ERSDA, MARA-ERNAM) WHERE MATNR = MARA-MATNR.
WHEN 'CLEAR'.
CLEAR MARA.
ENDCASE.
ENDMODULE.                 " STATUS_0101  OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0101 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0101 INPUT.
ENDMODULE.                 " USER_COMMAND_0101  INPUT

Click on middle Icon .

Enter MARA in the Table/Fieldname Text Box Then click on Get From Dictionary.

Select the require fields and click on continue.

Insert these boxes on the screen.

You can view like this after placing the boxes.


Create require Push buttons from toolbox.

Create require check box from toolbox.

Give the required Name , Text and Function Code Name .

Click on Save, Check and Activate.

Output:

Enter the Material number and Press Display.

Click on Display.

Values are displayed as shown below.

Similarly You Can View Clear And Exit.

Clear – It will clear all the displayed contents.

Exit - It will return to code..

We can Use the same operation in Function Keys.

  • F5 Clear
  • F6 Display
  • F7 Exit.

Enter the Material and Press F6 .

The same functionality F5 to Clear and F7 to Exit.