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

How to the variable from the other program

Former Member
0 Likes
1,143

Hi sap guys,

Consider there are two programs. That is Program A and Program B.

Now i want to use one variable in program A from program B.

How to do this?

Please Help Me on This

Thanks

Basu

Hi sap guys,

Consider there are two programs. That is Program A and Program B.

Now i want to use one variable in program A from program B.

How to do this?

Please Help Me on This

Thanks

Basu

6 REPLIES 6
Read only

Former Member
0 Likes
1,086

Hi,

using set/get parameter id You can Pass the Value from one program to another program.

PARAMETER:INPUT(30).

SET PARAMETER ID 'EXAMPLE' FIELD input.

submit ZEXAMPL1 VIA SELECTION-SCREEN AND RETURN.

report zexample1.

DATA:VAR TYPE SY-UCOMM.

GET PARAMETER ID 'EXAMPLE' FIELD VAR.

write:/ var.

Thanks,

Reward If Helpful.

Read only

Former Member
0 Likes
1,086

using Submit .

means submit one program B inside the Program A .

Example :

REPORT  demo_program_submit_rep1.

DATA number TYPE i.
PARAMETERS      paramet(14) TYPE c.
SELECT-OPTIONS  selecto FOR number.

The program DEMOdemo_program_submit_rep1 is called by the following program using various parameters:

REPORT demo_program_submit_sel_screen NO STANDARD PAGE HEADING.

DATA: int TYPE i,
      rspar TYPE TABLE OF rsparams,
      wa_rspar LIKE LINE OF rspar.

RANGES seltab FOR int.

WRITE: 'Select a Selection!',
     / '--------------------'.
SKIP.

FORMAT HOTSPOT COLOR 5 INVERSE ON.
WRITE: 'Selection 1',
     / 'Selection 2'.

AT LINE-SELECTION.
  CASE sy-lilli.
    WHEN 4.
      seltab-sign = 'I'. seltab-option = 'BT'.
      seltab-low  = 1.   seltab-high   = 5.
      APPEND seltab.
      SUBMIT demo_program_submit_rep1 VIA SELECTION-SCREEN
                      WITH paramet eq 'Selection 1'
                      WITH selecto IN seltab
                      WITH selecto ne 3
                      AND RETURN.
    WHEN 5.
      wa_rspar-selname = 'SELECTO'. wa_rspar-kind = 'S'.
      wa_rspar-sign = 'E'. wa_rspar-option = 'BT'.
      wa_rspar-low  = 14.  wa_rspar-high = 17.
      APPEND wa_rspar TO rspar.
      wa_rspar-selname = 'PARAMET'. wa_rspar-kind = 'P'.
      wa_rspar-low  = 'Selection 2'.
      APPEND wa_rspar TO rspar.
      wa_rspar-selname = 'SELECTO'. wa_rspar-kind = 'S'.
      wa_rspar-sign = 'I'. wa_rspar-option = 'GT'.
      wa_rspar-low  = 10.
      APPEND wa_rspar TO rspar.
      SUBMIT demo_program_submit_rep1 VIA SELECTION-SCREEN
                      WITH SELECTION-TABLE rspar
                      AND RETURN.
  ENDCASE.

Reward points if it is usefull ...

Girish

Read only

former_member404244
Active Contributor
0 Likes
1,086

Hi,

using set/get parameter id You can Pass the Value from one program to another program.

reward if helpful..

Regards,

nagaraj

Read only

Former Member
0 Likes
1,086

Use EXPORT/IMPORT statement.

Export the value of the variable from program B to a memory id and then import the value of memory id in program A.

This will work only if program A is called internally from Program B.

But if these two programs needs to be run independent of each other then use SET/GET parameter id.

Reward if useful.

Read only

Former Member
0 Likes
1,086

Hi,

It can be done with the use of <b>get/set</b> parameters,

I think it can also done with <b>include</b> program, keep A as include to B.

Regards

Read only

former_member195698
Active Contributor
0 Likes
1,086

Hi,

You can also use the method of 'Common Part' to share the variables in two different programs.

http://help.sap.com/saphelp_46c/helpdata/en/9f/db97c435c111d1829f0000e829fbfe/frameset.htm