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

export to memory id

Former Member
0 Likes
1,039

why is the flag not imported to the called sub program when calling from main program.

program main:

data: flag(1) type c value 'y'. " to indicate called from main program

data: mem1(60) type c. " import zprogram output

mem1 = 'S'.

data: mem2(60) type c. " export flag to mem2

mem2 = 'p'.

export flag to MEMORY ID mem2.

submit zprogram

and return

IMPORT internaltable FROM MEMORY id mem1.

program sub.

data: flag(1) type c. " to indicate called from main

data: mem1(60) type c. " import zprogram output

key = 'S'.

data: mem2(60) type c. " export flag to mem2

mem2 = 'p'.

IMPORT flag from memory id mem2.

if flag = 'y'.

EXPORT internaltable TO MEMORY id mem1.

ENDIF.

1 REPLY 1
Read only

Former Member
0 Likes
473

You have some syntax issues. Refer to the code below. The field FLAG carries the value of 'y' through to the called program ZSUB_Prog in this example. In your example, you were calling program ZPROGRAM; and your attached code was program ZSUB.

Program 1

REPORT ZMain .

data: flag(1) type c value 'y'. " to indicate called from main program

data: mem1(60) type c. " import zprogram output

mem1 = 'S'.

data: mem2(60) type c. " export flag to mem2

mem2 = 'p'.

export flag to MEMORY ID mem2.

submit ZSUB_Prog and return.

*Your logic here.

Program 2

REPORT ZSUB_Prog message-id zz.

data: flag(1) type c. " to indicate called from main

data: mem1(60) type c. " import zprogram output

*key = 'S'.

data: mem2(60) type c. " export flag to mem2

mem2 = 'p'.

IMPORT flag from memory id mem2.

if flag = 'y'.

    • Your logic here.

ENDIF.