Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SUBMIT inside loop.

Former Member
0 Likes
2,998

Hi all,

I need to pass single parameter value form my z-program to standard sap program excute it and come back to calling program to pass another value using SUBMIT statement inside loop. Snippet of code is -

LOOP AT it_zqac_purorg INTO wa_zqac_purorg WHERE sel_ind EQ 'X'.

LOOP AT it_ekorg INTO wa_ekorg WHERE ekorg = wa_zqac_purorg-ekorg.

range_line-sign = 'E'.

range_line-option = 'EQ'.

range_line-low = wa_ekorg-lifnr.

APPEND range_line TO range_tab.

ENDLOOP.

IF range_tab[] IS NOT INITIAL.

SUBMIT rm06lbat

TO SAP-SPOOL

SPOOL PARAMETERS params

USING SELECTION-SCREEN 1000

WITH lifnr IN range_tab

WITH ekorg = wa_zqac_purorg-ekorg

WITH gschl = '03'

EXPORTING LIST TO MEMORY

AND RETURN.

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

listobject = itab_list

EXCEPTIONS

not_found = 4

OTHERS = 8.

ENDIF.

CLEAR: wa_ekorg,wa_zqac_purorg.

ENDLOOP.

But the issue is if there are 10 record to be passed one at a time to called program the output of arlier 9 records is getting flushed from the memory.i.e.output of only 10th record is obtained. I will be thankful if any body can help in this regard.

Else help for 'Job sheduling of called program using SUBMIT' aproach will also do so that output for all the 10 records are obtained.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,437

Try it this way:

LOOP AT it_zqac_purorg INTO wa_zqac_purorg WHERE sel_ind EQ 'X'.

  LOOP AT it_ekorg INTO wa_ekorg WHERE ekorg = wa_zqac_purorg-ekorg.

    range_line-sign = 'E'.
    range_line-option = 'EQ'.
    range_line-low = wa_ekorg-lifnr.
    APPEND range_line TO range_tab.

  ENDLOOP.
  IF range_tab[] IS NOT INITIAL.

    SUBMIT rm06lbat
    TO SAP-SPOOL
    SPOOL PARAMETERS params
    USING SELECTION-SCREEN 1000
    WITH lifnr IN range_tab
    WITH ekorg = wa_zqac_purorg-ekorg
    WITH gschl = '03'
    EXPORTING LIST TO MEMORY
    AND RETURN.

    CALL FUNCTION 'LIST_FROM_MEMORY'
      TABLES
        listobject = itab_list
      EXCEPTIONS
        not_found  = 4
        OTHERS     = 8.

    CALL FUNCTION 'WRITE_LIST'
      TABLES
        listobject = itab_list
      EXCEPTIONS
        empty_list = 1
        OTHERS     = 2.

    CALL FUNCTION 'LIST_FREE_MEMORY'
      TABLES
        listobject = itab_list.

  ENDIF.

  CLEAR: wa_ekorg,wa_zqac_purorg.
ENDLOOP.

Rob

2 REPLIES 2
Read only

Former Member
0 Likes
1,437

Hello,

try to create a 2nd internal table (same structure than itab_list). After calling fm LIST_FROM_MEMORY, you should append the data of itab_list to this 2nd table. After the 10th loop, the complete results should be in your 2nd table.

Best regards

Stephan

Read only

Former Member
0 Likes
1,438

Try it this way:

LOOP AT it_zqac_purorg INTO wa_zqac_purorg WHERE sel_ind EQ 'X'.

  LOOP AT it_ekorg INTO wa_ekorg WHERE ekorg = wa_zqac_purorg-ekorg.

    range_line-sign = 'E'.
    range_line-option = 'EQ'.
    range_line-low = wa_ekorg-lifnr.
    APPEND range_line TO range_tab.

  ENDLOOP.
  IF range_tab[] IS NOT INITIAL.

    SUBMIT rm06lbat
    TO SAP-SPOOL
    SPOOL PARAMETERS params
    USING SELECTION-SCREEN 1000
    WITH lifnr IN range_tab
    WITH ekorg = wa_zqac_purorg-ekorg
    WITH gschl = '03'
    EXPORTING LIST TO MEMORY
    AND RETURN.

    CALL FUNCTION 'LIST_FROM_MEMORY'
      TABLES
        listobject = itab_list
      EXCEPTIONS
        not_found  = 4
        OTHERS     = 8.

    CALL FUNCTION 'WRITE_LIST'
      TABLES
        listobject = itab_list
      EXCEPTIONS
        empty_list = 1
        OTHERS     = 2.

    CALL FUNCTION 'LIST_FREE_MEMORY'
      TABLES
        listobject = itab_list.

  ENDIF.

  CLEAR: wa_ekorg,wa_zqac_purorg.
ENDLOOP.

Rob