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

Executing a program multiple times automatically

Former Member
0 Likes
1,264

Hi All,

I need to write an abap program which takes a list of inputs from a flat file and executes another program that many number

of times.

Eg if my file contains AAA,BBB,CCC values then these values should be passed to another prog say Z_XYZ which will get

execute three times automatically using the corresponding values AAA,BBB,CCC as inputs .

Thanks,

Faiz

7 REPLIES 7
Read only

schneidertho
Product and Topic Expert
Product and Topic Expert
0 Likes
1,102
Read only

0 Likes
1,102

Hi Thorsten,

Using Submit we can pass the data to the selection screen,but I want to execute the program multiple times using different data as I had expalined above.

Can u pls give a detailed explanation on how to achieve this.

Thanks,

Faiz

Read only

schneidertho
Product and Topic Expert
Product and Topic Expert
0 Likes
1,102

Hi Faiz,

have you tried calling the program via SUBMIT inside a loop (with addition SUBMIT... AND RETURN)... and using the possibilities in the linked documentation to fill the selection screen? That should work as far as I know.

Or is your requirement to run the reports in parallel?


Best regards

Thorsten

Read only

0 Likes
1,102

Hi Thorsten,

I'll explain my requirement in detail.

My file contains these values - AAA,BBB,CCC .Now I want to create a prog(prog 1),which will take these 3 values from the file pass these values to the selection screen of prog2 one by one and using these values it will execute prog2 , three times and generate 3 outputs for the corresponding 3 input values.

Regards,

Faiz

Read only

0 Likes
1,102

Hi Faiz,

but that's exactly what you can achieve with Thorsten's solution using SUBMIT ... AND RETURN.

Regards,

Dirk

Read only

schneidertho
Product and Topic Expert
Product and Topic Expert
0 Likes
1,102

Hi Faiz,

I believe when you read the attached links, you will understand how to do it.

Anyway... I had created a simple test report sometime ago. I just added three variables to show the basic approach in your case. Maybe it helps.

(I know there is a better way to format code in SCN, but somehow it does not work properly...)

REPORT zts_report1.

PARAMETERS: p_arbgb TYPE t100-arbgb.

DATA: gs_t100 TYPE t100.

SELECT * FROM t100 INTO gs_t100
         WHERE arbgb = p_arbgb
           AND sprsl = sy-langu.
  WRITE: / gs_t100-arbgb, space, gs_t100-msgnr, space, gs_t100-text.
ENDSELECT.

REPORT zts_report2.

PARAMETERS: p_arbgb1 TYPE t100-arbgb.
PARAMETERS: p_arbgb2 TYPE t100-arbgb.
PARAMETERS: p_arbgb3 TYPE t100-arbgb.

DATA: gv_index TYPE sy-index,
      gt_rspar TYPE STANDARD TABLE OF rsparams,
      gs_rspar TYPE rsparams,
      gt_listobject TYPE STANDARD TABLE OF abaplist.

DO 3 TIMES.
  gv_index = sy-index.
  CLEAR: gt_rspar[],
         gs_rspar.
  gs_rspar-selname = 'P_ARBGB'.
  gs_rspar-kind = 'P'.
  CASE gv_index.
    WHEN 1.
      gs_rspar-low = p_arbgb1.
    WHEN 2.
      gs_rspar-low = p_arbgb2.
    WHEN 3.
      gs_rspar-low = p_arbgb3.
  ENDCASE.
  APPEND gs_rspar TO gt_rspar.

  SUBMIT zts_report1 WITH SELECTION-TABLE gt_rspar
         EXPORTING LIST TO MEMORY AND RETURN.

  CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
      listobject = gt_listobject[]
    EXCEPTIONS
      not_found  = 1
      OTHERS     = 2.
  CALL FUNCTION 'WRITE_LIST'
    TABLES
      listobject = gt_listobject[]
    EXCEPTIONS
      empty_list = 1
      OTHERS     = 2.
ENDDO.

Best regards

Thorsten

Read only

0 Likes
1,102

Thanks Thorsten for ur help...I will surely try this and get back to u..