Application Development 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: 

Calling a program from another program

Former Member
0 Kudos

Hi All,

I have program A and program B, need to call prg B from prg A. and need to pass values from prg A as single values in selection criteria of prog B.

Please help me how to call.

Answers are highly rewarded

Thanks in advance

rk

1 ACCEPTED SOLUTION

suresh_datti
Active Contributor
0 Kudos

Use the SUBMIT statement in Program A.. something like.


SUBMIT <progrm B> with <parameter>  = <value>
                       <parameter>  = <value>
                        .....
 AND RETURN.

Also pl check this

<a href="http://help.sap.com/saphelp_47x200/helpdata/en/9f/dba51a35c111d1829f0000e829fbfe/frameset.htm">SAP Help</a>

Regards,

Suresh Datti

9 REPLIES 9

suresh_datti
Active Contributor
0 Kudos

Use the SUBMIT statement in Program A.. something like.


SUBMIT <progrm B> with <parameter>  = <value>
                       <parameter>  = <value>
                        .....
 AND RETURN.

Also pl check this

<a href="http://help.sap.com/saphelp_47x200/helpdata/en/9f/dba51a35c111d1829f0000e829fbfe/frameset.htm">SAP Help</a>

Regards,

Suresh Datti

0 Kudos

Suresh has your solution. Just wanted to make you aware that this also works for select-options as well.

SUBMIT <progrm B> with <selectoption> in <r_value>
                        with <selectoption> in  = <r_value>
                        .....
 AND RETURN.

Also, you can pass values and internal tables thru memory.

In your program a....

export itab = itab to memory id 'ZTEST'.
submit <report> and return.

In program B.....

import itab = itab from memory id 'ZTEST'.

Regards,

Rich Heilman

0 Kudos

Hi,

prog A has internal table with one field and contains multiple records, have to pass this table into selection screen field-low(Range) in Prog B.

Thanks

Raj

0 Kudos

you the import export as Rich mentioned and then create range in program B and include all values form internal table into LOW field of range.

Then you can use range any where in program B.

Regards

Aman

0 Kudos

Sure, see the sample program below. Here we are taking values from the itab and building our RANGE, then we are passin this RANGE to the select-option of the submitted program.



report zrich_0001.

data: begin of itab occurs 0,
      datum type sy-datum,
      end of itab.

<b>ranges: r_datum for sy-datum.</b>

* create some data in ITAB
itab-datum = sy-datum.
do 10 times.
  itab-datum = itab-datum  + 1.
  append itab.
enddo.

<b>


* Build the range
clear r_datum. refresh r_datum.
loop at itab.
  r_datum-sign = 'I'.
  r_datum-option = 'EQ'.
  r_datum-low = itab-datum.
  append r_datum.
endloop.</b>

submit zreport
<b>    with s_datum in  r_datum</b>
          and return.

Regards,

Rich Heilman

aris_hidalgo
Contributor
0 Kudos

Hello,

below is an example:

IF NOT v_kunnr IS INITIAL.

SUBMIT zdealer_contacts_add_edit AND RETURN

WITH p_kunnr = v_kunnr

WITH p_name1 = p_name1 "AVH

WITH p_cdseq = space

WITH p_flag = 'A'

WITH p_addr = it_zts0001-zaddress

WITH p_pers = it_zts0001-zcperson

WITH p_numb = it_zts0001-zcnumber

VIA SELECTION-SCREEN.

ENDIF.

it calls program zdealer_contacts_add_edit and pass the values above.

Reagrds!

Former Member
0 Kudos

Hi,

There are two ways , The first way is using Sumit statement.And second by using function module

Rzl_submit.

If it helps out, Please award suitable points and close the thread.

Regards,

Irfan Hussain

Former Member
0 Kudos

HI

GOOD

TRY WITH THIS

  • and return - returns to the calling program

submit zxxxx via selection-screen and return.

  • ZX refers to the variant.

submit zxxxx via selection-screen using selection-set 'ZX' and return.

THANKS

MRUTYUN

ferry_lianto
Active Contributor
0 Kudos

Hi Raj,

You code something like this.

ranges: r_matnr for mara-matnr.

loop at <internal table>.
  r_matnr-sign   = 'I'.
  r_matnr-option = 'EQ'.
  r_matnr-low    = <internal table>-<field name>.
  append r_matnr.
endloop.

...

submit <program b> with s_matnr in r_matnr
                   and return.

Hope this will give you an idea.

Regards,

Ferry Lianto