Skip to Content

This post is about selection screen with tabs. Selection screen with tabs are not that hard to implement on ABAP and I am sure if you search online you will always get the code for it…. but just to start things ill just give the code no a basic selection screen with tabs…

 

 SELECTION-SCREEN BEGIN OF SCREEN 101 AS SUBSCREEN .

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
            
SELECT-OPTIONS: s_ebeln FOR zconf_stage-ebeln,
                s_ebelp FOR zconf_stage-ebelp,
                s_bsart FOR ekko-bsart,
                s_werks FOR ekpo-werks,
                s_matnr FOR ekpo-matnr,
                s_lifnr FOR ekko-lifnr,
                s_ekgrp FOR ekko-ekgrp,
                s_budat FOR zconf_stage-budat,
                s_kunnr FOR vbpa-kunnr.
SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN END OF SCREEN 101.

SELECTION-SCREEN BEGIN OF SCREEN 102 AS SUBSCREEN .

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-001.

SELECT-OPTIONS: s_ebeln1 FOR zconf_stage-ebeln,
                s_bsart1 FOR ekko-bsart,
                s_werks1 FOR ekpo-werks ,
                s_matnr1 FOR ekpo-matnr,
                s_lifnr1 FOR ekko-lifnr,
                s_ekgrp1 FOR ekko-ekgrp,
                s_budat1 FOR zconf_stage-budat,
                s_kunnr1 FOR vbpa-kunnr.
SELECTION-SCREEN END OF BLOCK b2.

SELECTION-SCREEN END OF SCREEN 102.

SELECTION-SCREEN: BEGIN OF TABBED BLOCK mytab FOR 24 LINES,
TAB (30) button1 USER-COMMAND on,
TAB (30) button2 USER-COMMAND auto,
END OF BLOCK mytab.

INITIALIZATION.
  button1 = text-011.
  button2 = text-012.

  mytab-prog = sy-repid.
  mytab-dynnr = 101.
  mytab-activetab = ‘BUTTON1’.

AT SELECTION-SCREEN .

  IF sy-batch = ‘X’.
    mytab-dynnr = 102.
    mytab-activetab = ‘BUTTON2’.
    sy-ucomm = ‘AUTO’.
  ENDIF.

  CASE sy-dynnr.

    WHEN 1000.
      CASE sy-ucomm.
        WHEN ‘ON’.
          mytab-dynnr = 101.
          mytab-activetab = ‘BUTTON1’.
        WHEN ‘AUTO’.
          mytab-dynnr = 102.
          mytab-activetab = ‘BUTTON2’.
      endcase.

    WHEN 0101.
      mytab-dynnr = 101.
      mytab-activetab = ‘BUTTON1’.
    WHEN ‘ONLI’.
          PERFORM screen_validation101.
      ENDCASE.

    WHEN 0102.
      mytab-dynnr = 102.
      mytab-activetab = ‘BUTTON2’.
      case sy-ucomm.
    WHEN ‘ONLI’.
          PERFORM screen_validation102.
      ENDCASE.
  ENDCASE.

START-OF-SELECTION.

  CASE mytab-activetab.
    WHEN ‘BUTTON1’.”online mode
    
    WHEN ‘BUTTON2’.” when automatic
     
  ENDCASE.

 

now the above code is to a selection screen with tabs that you code using a report program.( this code cannot be used in module pool program )

 

When a customer request to a selection screen with tabs there can be 2 reasons.

 

1) To group a selection on one out put ( I mean the final out-put is one but selection screen can be with tabs to make things clear for e.g on SD related report the tabs can be Material selection , SO selection like wise )

 

2) The user requires different kind of out comes with different tabs… for e.g tab no1 to work during online operations and tab no 2 to work on background operations.

 

The above requirement 1 which will be totally fine with the code given on top. But the requirement 2 will be a issue when it comes to the above code. As most of the developers know on a selection screen we will always have mandatory fields. when switching between tabs the selection screen first calls the validation and then it calls the normal screen code ( as you know the validation is automatic if me make a selection option mandatory and we have no say on it ). 

  So in case if the user wants the functionality of the tab 2 he first has to fill all the mandatory fields on tab 1 so that the error wont occur. This was a error I had to face during my development for this there are 2 way outs 

 

1) do the validation by your self ( draw back : you wont get the mandatory sign on the selection screen )

2) write a selection screen with tabs ( draw back : the user wont be able to save variants or this part has to be coded which will be a messy job ) 

 

for the 2nd option on above to make sure the tab switching with happen without first validating you have to do the codding as follows

 PROCESS BEFORE OUTPUT.
  MODULE STATUS_0100.
  MODULE set_tabs.

  call SUBSCREEN SUB INCLUDING sy-repid gv_dynnr.
*
PROCESS AFTER INPUT.

  MODULE exit_comm.
  MODULE switch_tab.
  CALL SUBSCREEN SUB.
  MODULE screen_comm.

  MODULE USER_COMMAND_0100.

 

before call sub screen you have to call a module switch tabs. 

 

on my case my customer wanted the variants to be there. Therefore they agreed to the validation by code where the mandatory sign is not displayed.

 

updates>>>>>>

by Andreas Loch

If you do the validation yourself you still can have the mandatory sign. To achieve this you have to define the field as ‘recommended’ instead of required.

Example code for your report:

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    IF screen-name EQ ‘S_WERKS-LOW’.
      screen-required = 2. “2 is recommended
    ENDIF.
    MODIFY SCREEN.
  ENDLOOP.

To report this post you need to login first.

8 Comments

You must be Logged on to comment or reply to a post.

  1. Andreas Loch
    If you do the validation yourself you still can have the mandatory sign. To achieve this you have to define the field as ‘recommended’ instead of required.

    Example code for your report:

    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
        IF screen-name EQ ‘S_WERKS-LOW’.
          screen-required = 2. “2 is recommended
        ENDIF.
        MODIFY SCREEN.
      ENDLOOP.

    (0) 
    1. Nafran Shiraz Post author
      Hi Thanks for that point. I knew we can do recommenced on module pool screen. but I didn’t know by making the screen field required we can get it done.

      Thanks a lot for the info.

      (0) 
      1. Juwin Thomas
        Hi,

        If you do module pool screen, on a selection screen, I do not think the user will be able to save variants, for the fields included in module pool screen. Using the “Recommended” option, along with custom validation logic, seems to be better.

        Thanks,
        Juwin

        (0) 
          1. Juwin Thomas
            I don’t get it. If you used the “Recommended” option, and that seems to be definitely better than module pool, then why does the Blog say to use module pool? Somebody should edit the Blog and get it corrected.

            Thanks,
            Juwin

            (0) 
            1. Nafran Shiraz Post author
              HI juwin,
              the blog does not say the module pool is the best , it was just to give a option that you can even use module pool. I have clearly said that i used the report option.

              plus the recommended option was found out later. so at the beginning the report was developed with out the mandatory sing but just by giving the mandatory error message.

              (0) 

Leave a Reply