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

function module

former_member188827
Active Contributor
0 Likes
489

hi all,

i want to save two numeric values in a function module ztest.one program has to pass these values & the other program retrieves these values ie

report zprog.

CALL FUNCTION 'Ztest'

EXPORTING

ZACC = zacc

ZAMT = amt

  • IMPORTING

  • ZACC1 =

  • ZAMT1 =

in my program i have two data variables zacc type i & amt type i.

zacc = 2.

amt = 3.

<b>in the other program i have to fetch these values how to do it?

report zprog1.

CALL FUNCTION 'Ztest'

  • EXPORTING

  • ZACC =

  • ZAMT =

IMPORTING

ZACC1 =

ZAMT1 =</b>

.

rgds

4 REPLIES 4
Read only

Former Member
0 Likes
446

Hi

U should use IMPORT/EXPORT statament to export that data to memory from program zprog and import them from memory by program zprog1.

Max

Read only

Former Member
0 Likes
446

Hi,

Just call this FM in both the programs.

Program1:

" zacc and zamt are two variable in this program1

zacc = 2.

zamt = 3.

CALL FUNCTION 'Ztest'

EXPORTING

ZACC = zacc

ZAMT = amt

  • IMPORTING

  • ZACC1 =

  • ZAMT1 =

Program2:

CALL FUNCTION 'Ztest'

EXPORTING

*ZACC =

*ZAMT =

IMPORTING

ZACC1 = zacc2

ZAMT1 = zamt2

" zacc2and zamt2 are two variable in this program2

And one important thing is <b>YOU MUST PUT IMPORT AND EXPORT PARAMETERS AS OPTIONAL</b>.OK

Hope,Your problem is solved.

Reward,if helpful.

Regards,

V.Raghavender.

Read only

Former Member
0 Likes
446

USE IN PROG1

EXPORT ZACC TO MEMORY ID 'ZAC'.

EXPORT AMT TO MEMORY ID 'AMT'.

IN PROG 2.

IMPORT ZACC FROM MEMORY ID 'ZAC'.

IMPORT AMT FROM MEMORY ID 'AMT'.

REGARDS

SHIBA DUTTA

Read only

Former Member
0 Likes
446

abap user,

Pass zacc = 2. amt = 3. to abap memory and submit the prog1 and in prog1 import the values and pass these to your FM and take the output values there itself.

In the below code i have passed internal table alos.Remove that.

For this example

PROGRAM SAPMZTS1.

DATA TEXT1(10) VALUE 'Exporting'.

DATA ITAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.

DO 5 TIMES.

ITAB-BOOKID = 100 + SY-INDEX.

APPEND ITAB.

ENDDO.

EXPORT TEXT1

TEXT2 FROM 'Literal'

TO MEMORY ID 'text'.

EXPORT ITAB

TO MEMORY ID 'table'.

SUBMIT SAPMZTS2 AND RETURN.

SUBMIT SAPMZTS3.

The first part of this program is the same as the example in the section Saving Data Objects in Memory. In the example, the programs SAPMZTS1 and SAPMZTS2 are called using SUBMIT. You can create and maintain the programs called using the SUBMIT statement by double-clicking their names in the statement. For further information about the SUBMIT statement, refer to Calling Executable Programs (Reports)

Example for SAPMZTS2:

PROGRAM SAPMZTS2.

DATA: TEXT1(10),

TEXT3 LIKE TEXT1 VALUE 'Initial'.

IMPORT TEXT3 FROM MEMORY ID 'text'.

WRITE: / SY-SUBRC, TEXT3.

IMPORT TEXT2 TO TEXT1 FROM MEMORY ID 'text'.

WRITE: / SY-SUBRC, TEXT1.

Example for SAPMZTS3:

PROGRAM SAPMZTS3.

DATA JTAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.

IMPORT ITAB TO JTAB FROM MEMORY ID 'table'.

LOOP AT JTAB.

WRITE / JTAB-BOOKID.

ENDLOOP.

Don't forget to reward if useful..