cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP Calling last calling program in the stack

saurabh_shukla4
Explorer
451

Hello experts,

  I have a program (dialog program - scr 400) screen and button on the screen. It's calling another program (+ transaction) having selection screen and after execution ALV grid displayed. After performing work it should back to original calling screen having dialog program screen (400).

ZPROGRAM1 (Screen 400) -> Call Transaction - ZPROGRAM2 (+selection screen) -> ALV screen and then back with same sequence.

We have tried with, AT SELECTION SCREEN EXIT-COMMAND and leave 0 or set screen 0 but somehow it is not working. CALL SCREEN will not work since it back button is in another program which is called.

How to call previous screens which are in call stack.

Regards,

PD

Sandra_Rossi
Active Contributor
What is your issue? Leaving the ALV screen and go back to the selection screen? Leaving the selection screen? Then post the relevant code. No need to mix your question with Web Dynpro and CALL TRANSACTION.
View Entire Topic
saurabh_shukla4
Explorer
0 Kudos

@ulrich_mhrke 

Below is the code of PAI of ZPROG1 (Screen 400)

 

MODULE user_command_0400 INPUT.
 CASE sy-ucomm.
    WHEN 'NEWMAT'.
      "test run
      SET PARAMETER ID 'OPTION' FIELD 'MAT'.
      CALL TRANSACTION 'ZTRANS'.

 

This code is calling selection screen of ZTRANS transaction.

 

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
PARAMETERS : cust  RADIOBUTTON GROUP g1 DEFAULT 'X'  USER-COMMAND cmd  MODIF ID upd,

 

and some more parameters at selection screen.
Once selection screen is executed it is calling ALV grid using REUSE_ALV_GRID_DISPLAY function. Once grid is displayed and back is pressed then it again comes back to selection screen of ZTRANS. From here, if we press back, then it exits the transaction and not going back to screen 400 of ZPROG1.
We have tried to use AT SELECTION-SCREEN ON EXIT-COMMAND. Also under ZTRANS program and in that we tried to use SET SCREEN 0 or CALL TRANSACTION (of 400 screen) but it's not going back to screen 400.

About your second question, attribute of screen 400 (next screen) is set to 400 and it is not empty.

 

Sandra_Rossi
Active Contributor
0 Kudos
Please don't post an answer for comments, additional details. Answer is reserved to propose a solution. Instead, use Replies > Comment (on the question or on a proposed answer).
ulrich_mhrke
Explorer
0 Kudos
Please send the WHOLE flow logic of screen 400 of program ZPROG1 and the WHOLE PAI module where you call transaction ZTRANS. You will find the flow logic at screen definition. It should start with "PROCESS BEFORE OUTPUT". The code of the module starts with "MODULE ... INPUT." and ends with "ENDMODULE."
saurabh_shukla4
Explorer
0 Kudos

@ulrich_mhrke

This is screen flow logic:

PROCESS BEFORE OUTPUT.
  MODULE status_0400.

PROCESS AFTER INPUT.
  MODULE user_command_0400.


PROCESS ON VALUE-REQUEST.

And for Module user_command_400.

 CASE sy-ucomm.
    WHEN 'NEWMAT'.
      "test run
      SET PARAMETER ID 'OPTION' FIELD 'MAT'.
      CALL TRANSACTION 'ZTRANS'.

 NEWMAT is function key declared for the button on screen 400. 

ulrich_mhrke
Explorer
For some reason you don't want to give us the whole code of module user_command_400. Maybe you can add an info message direct after the call screen (message 'Some text.' type 'I'.). Do you see this message after returning from the called transaction?
Sandra_Rossi
Active Contributor
0 Kudos
@saurabh_shukla4 A simple way to discuss efficiently is to create a small test program to reproduce the issue and post it (of course, sharing via a Git repository is the best way when it concerns non-ABAP objects like Dynpro, these objects can be uploaded/downloaded in an instant via abapGit).
saurabh_shukla4
Explorer
0 Kudos

@ulrich_mhrke

Please find screenshots of the development:

Screen 400: PAI

img1_400.png

PAI User-command:

400_attribute.png

Screen 400 Attribute

400_pai.png

Call Transaction (ZUPLOADRPA) - previously ZTRANS now name has changed.

 

selection_screen.png

Called transaction selection screen attribute.

As mentioned, the selection screen of another program ZUPLOADRPA (old name - ZTRANS) is getting called successfully and also ALV grid further. Back from ALV grid is also working to selection screen. But after selection screen the program is not returning to 400 transaction screen

 

ulrich_mhrke
Explorer
0 Kudos
Why I asked for the whole code of the module?: Also in your picture we can not see if there is some more code between "ENDCASE." and "ENDMODULE."
saurabh_shukla4
Explorer
0 Kudos

@ulrich_mhrke

Hi, sorry for the late reply, I am not hesitating to share the code as only this much code is available. I will try more to add as below:
Screen 400 flow logic:

PROCESS BEFORE OUTPUT.
  MODULE status_0400.

PROCESS AFTER INPUT.
  MODULE user_command_0400.


PROCESS ON VALUE-REQUEST.
  "  FIELD SOLDTONEW MODULE SOLDTO_F4.
  " FIELD SHIPTONEW MODULE SHIPTO_F4.
  "  FIELD CURRENCYNEW MODULE CURRENCYNEW_F4.
  " FIELD MATNONEW MODULE MATNONEW_F4.
  " FIELD stprs MODULE unitc0st_f4.

Below is user-command module for screen 400:

MODULE user_command_0400 INPUT.

  SELECT SINGLE bezei INTO @DATA(wa_bezei) FROM tinct WHERE inco1 = @inco1 AND spras EQ @sy-langu.
  IF sy-subrc EQ 0.
    inco2 = wa_bezei.
  ENDIF.

  SELECT SINGLE name1 FROM kna1 INTO @DATA(name1) WHERE kunnr = @soldtonew.
  IF sy-subrc EQ 0.
    soldto = name1.
  ENDIF.
  CLEAR name1.
  SELECT SINGLE name1 FROM kna1 INTO @name1 WHERE kunnr = @shiptonew.
  IF sy-subrc EQ 0.
    shipto = name1.
    CLEAR name1.
  ENDIF.
  SELECT SINGLE maktg FROM makt INTO @DATA(maktg_v) WHERE matnr = @matnonew.
  IF sy-subrc EQ 0.
    maktg = maktg_v.
    CLEAR maktg_v.
  ENDIF.

  unit = unit.

  "SELECT SINGLE vkorg, vtweg, spart FROM knvv INTO @DATA(wa_knvv) WHERE kunnr = @soldtonew.
  "IF sy-subrc EQ 0.
  " vkorg = wa_knvv-vkorg.
  "vtweg = wa_knvv-vtweg.
  "spart = wa_knvv-spart.
  "CLEAR wa_knvv.
  "ENDIF.

*  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
*    EXPORTING
*      input  = matnonew
*    IMPORTING
*      output = matnonew.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      input  = soldtonew
    IMPORTING
      output = soldtonew.

  REFRESH: t_a005[], lt_konp[].

  SELECT * FROM a005 INTO TABLE t_a005 WHERE kappl =  'V' AND kschl =  'ZPR1' AND vkorg = vkorg AND vtweg = vtweg AND kunnr = soldtonew AND matnr = matnonew  AND datbi >= sy-datum.
  IF sy-subrc = 0.
    SELECT knumh kopos kschl kbetr konwa kpein kmein krech loevm_ko mwsk1 kznep stfkz kzbzg
      FROM konp APPENDING TABLE lt_konp
      FOR ALL ENTRIES IN t_a005 WHERE
      knumh = t_a005-knumh AND
      kschl = t_a005-kschl.
    IF sy-subrc = 0.
      LOOP AT lt_konp INTO ls_konp.
        unit = ls_konp-kbetr.
        EXIT.
      ENDLOOP.
    ENDIF.
  ELSE.

    DATA matnonew_1 TYPE mara-matnr.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = matnonew
      IMPORTING
        output = matnonew_1.


    SELECT * FROM a005 INTO TABLE t_a005 WHERE kappl =  'V' AND kschl =  'ZPR1' AND vkorg = vkorg AND vtweg = vtweg AND kunnr = soldtonew AND matnr = matnonew_1  AND datbi >= sy-datum.
    IF sy-subrc = 0.
      SELECT knumh kopos kschl kbetr konwa kpein kmein krech loevm_ko mwsk1 kznep stfkz kzbzg
    FROM konp APPENDING TABLE lt_konp
    FOR ALL ENTRIES IN t_a005 WHERE
    knumh = t_a005-knumh AND
    kschl = t_a005-kschl.
      IF sy-subrc = 0.
        LOOP AT lt_konp INTO ls_konp.
          unit = ls_konp-kbetr.
          EXIT.
        ENDLOOP.
      ENDIF.
    ENDIF.
  ENDIF.


  CASE sy-ucomm.
    WHEN 'FNEXIT'.
      PERFORM exit_screen_400.
    WHEN 'FNADD'.
      add_btn_clicked_400 = 1.
      save_btn_clicked_400 = 0.
      change_btn_clicked_400 = 0.
      delete_btn_clicked_400 = 0.
      PERFORM add_item_400.
    WHEN 'FNCHANGE'.
      add_btn_clicked_400 = 0.
      change_btn_clicked_400 = 1.
      delete_btn_clicked_400 = 0.
      save_btn_clicked_400 = 0.
      PERFORM change_item_400.
    WHEN 'FNSAVE'.
      save_btn_clicked_400 = 1.
      add_btn_clicked_400 = 0.
      change_btn_clicked_400 = 0.
      delete_btn_clicked_400 = 0.
      PERFORM save_orders_so.
    WHEN 'FNACCEPT'.
      PERFORM accept_item_changes_400.
    WHEN 'FNDELETE'.
      save_btn_clicked_400 = 0.
      add_btn_clicked_400 = 0.
      change_btn_clicked_400 = 0.
      delete_btn_clicked_400 = 1.
      PERFORM delete_item_400.
    WHEN 'FNCALC'.
      PERFORM calculate_sub_total.
    WHEN 'FNVERIFY'.
      "test run
      wa_testrun = 'X'.
      PERFORM prepare_bapi_data.
    WHEN 'FNPOST'.
      "test run
      CLEAR wa_testrun.
      PERFORM prepare_bapi_data.
    WHEN 'NEWMAT'.
      "test run
      SET PARAMETER ID 'OPTION' FIELD 'MAT'.
      CALL TRANSACTION 'ZUPLOADRPA'.
    WHEN 'NEWCUST'.
      SET PARAMETER ID 'OPTION' FIELD 'CUST'.
      CALL TRANSACTION 'ZUPLOADRPA' AND SKIP FIRST SCREEN.
      "SUBMIT ZUPLOADRPA VIA SELECTION-SCREEN AND RETURN.
  ENDCASE.
ENDMODULE.

When NEWMAT is being clicked (which is button on screen 400) the transaction ZUPLOADRPA is called. The program and transaction names are same.

Now at ZUPLOADRPA below is the selection screen.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
PARAMETERS : cust     RADIOBUTTON GROUP g1 DEFAULT 'X'  USER-COMMAND cmd  MODIF ID upd,
             vend     RADIOBUTTON GROUP g1 MODIF ID up1,
             mat      RADIOBUTTON GROUP g1 MODIF ID upm,
             raw      RADIOBUTTON GROUP g1 MODIF ID up1,
             halb     RADIOBUTTON GROUP g1 MODIF ID up1,

             bom      RADIOBUTTON GROUP g1  MODIF ID bom,
             altbom   RADIOBUTTON GROUP g1 MODIF ID bpd,
             exbom    RADIOBUTTON GROUP g1 MODIF ID bpd,
             moda     TYPE ctu_params-dismode OBLIGATORY DEFAULT 'A' MODIF ID bpd,

             routing  RADIOBUTTON GROUP g1 MODIF ID rot,
             altrot   RADIOBUTTON GROUP g1 MODIF ID rpd,
             exrot    RADIOBUTTON GROUP g1 MODIF ID rpd,


             hibe     RADIOBUTTON GROUP g1 MODIF ID up1,
             hawa     RADIOBUTTON GROUP g1 MODIF ID up1,
             vcust    RADIOBUTTON GROUP g1 MODIF ID up1,
             nlag     RADIOBUTTON GROUP g1 MODIF ID up1,
             rawext   RADIOBUTTON GROUP g1 MODIF ID up1,
             fertdesc TYPE zfertdesc MODIF ID upm.
*PARAMETERS : mod1 TYPE ctu_params-dismode DEFAULT 'A' OBLIGATORY  MODIF ID upd.
SELECTION-SCREEN END OF BLOCK b1.


AT SELECTION-SCREEN ON EXIT-COMMAND.

  "LEAVE to SCREEN 100.

The selection screen execution will display ALV grid as below:

 CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_buffer_active          = space
        i_callback_program       = sy-repid
        i_callback_pf_status_set = 'SET_PF_STATUS'
        i_callback_user_command  = 'CUST_USER_COMMAND'
        it_fieldcat              = t_field[]
        is_layout                = gd_layout
        i_save                   = 'A'
        i_default                = 'X'
      TABLES
        t_outtab                 = it_cust
      EXCEPTIONS
        program_error            = 1
        OTHERS                   = 2.
  

And at ALV grid user command module below is the code for back button PF1:

  ELSEIF ( ( sy-ucomm = 'PF1' ) OR ( sy-ucomm = 'PF2' ) OR ( sy-ucomm = 'PF3' ) ).
    LEAVE TO CURRENT TRANSACTION.
  ENDIF.

From here, back is pressed and the screen flow comes back to selection screen again.

But, after selection screen, and pressing back button at selection screen it is ending the transaction and not going back to the calling screen i.e. 400 PBO. Below is the 400 screen PBO:

ODULE status_0400 OUTPUT.
  SET PF-STATUS 'ZSCRPF_400'.
  SET TITLEBAR 'ZSCRT_400'.

  GET PARAMETER ID 'FILENAME' FIELD filename.

  PERFORM set_layout_list.
  IF initial_load = 'N'.
    PERFORM recalculate_overall_total.
  ENDIF.

  IF change_btn_clicked_400 EQ 0 AND add_btn_clicked_400 EQ 0
      AND delete_btn_clicked_400 EQ 0.
    IF initial_load EQ 'Y'.
      CLEAR: chkapplyall, chkdiscall, custmat, maktg,matnonew,qtynew, stprs, txtmsgs, sgstnew, cgstnew, igstnew, deldatenew, unit, basicamt, totalnew,kbetrnew, itemnobot, zzprdat,zzmfg_cdate ,zzrepeat, werks, lgort.
      initial_load = 'N'.
      PERFORM set_initial_values_of_header.
      PERFORM set_initial_values_of_items.
      PERFORM set_list_values.
    ENDIF.
    "PERFORM CLEAR_ITEM_VALUES.
  ENDIF.

  IF add_btn_clicked_400 EQ 1.
    "  PERFORM CLEAR_VALUES.
  ENDIF.

  IF save_btn_clicked_400 EQ 1.
    " PERFORM set_initial_values_400.
  ENDIF.

  IF change_btn_clicked_400 EQ 1.
    " PERFORM SET_VALUES_CHANGED_CLICKED.
  ENDIF.


  IF cust_items IS INITIAL.

    CREATE OBJECT cust_items
      EXPORTING
        container_name = 'CUST_ITEMS'.


    CREATE OBJECT grid_list
      EXPORTING
        i_parent = cust_items.


    CALL METHOD grid_list->set_table_for_first_display
      EXPORTING
*       i_buffer_active               =
*       i_bypassing_buffer            =
*       i_consistency_check           =
*       i_structure_name              =
*       is_variant                    =
*       i_save                        =
*       i_default                     = 'x'
        is_layout                     = is_layout_list
*       is_print                      =
*       it_special_groups             =
*       it_toolbar_excluding          =
*       it_hyperlink                  =
*       it_alv_graphics               =
*       it_except_qinfo               =
*       ir_salv_adapter               =
      CHANGING
        it_outtab                     = it_ybapi_item_rpa[]
        it_fieldcatalog               = it_fldcat_list[]
*       it_sort                       =
*       it_filter                     =
      EXCEPTIONS
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        OTHERS                        = 4.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.

    CALL METHOD grid_list->refresh_table_display.

  ELSE.
    CALL METHOD grid_list->refresh_table_display.
  ENDIF.
ENDMODULE.

Your help is appreciated in this.

Thanks,

Regards,

PD