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

can't getting DATA FROM ANOTHER PROGRAM USING FIELD-SYMBOL

sanjeeva_reddy9
Explorer
0 Likes
2,737

HI, MASTERS

I have written 2 z-programs one is to get the data

the second one is two fetch the data from the first program

here is the 1 st program

PARAMETERS p_matnr TYPE matnr DEFAULT '000000000000000023'.

DATA lt_makt TYPE STANDARD TABLE OF makt.
DATA ls_makt TYPE makt.

SELECT * FROM makt INTO table lt_makt WHERE matnr = p_matnr.

LOOP AT lt_makt INTO ls_makt.

WRITE : / ls_makt-matnr,
ls_makt-spras.

endloop.

2nd program is


parameters p_mat type matnr default '000000000000000023' NO-DISPLAY.

data: txtlines(1024) type c occurs 0 with header line.
TYPES LS_MAKT TYPE MAKT.

DATA lt_makt TYPE STANDARD TABLE OF makt.
SUBMIT ytest_sanju_submit EXPORTING LIST TO MEMORY AND RETURN
WITH p_matnr = p_mat.
IF sy-subrc <> 0.

ENDIF.

FIELD-SYMBOLS : <fs_makt> TYPE ANY TABLE. "makt.
DATA LV_FIELD(50) TYPE C .

lv_field = '(ytest_sanju_submit)ls_makt'.

ASSIGN (lv_field) to <fs_makt>.

the thing is i am not getting the value into the lv_field instead of value am getting the text

11 REPLIES 11
Read only

RaymondGiuseppi
Active Contributor
2,356

You paste twice the same code, so no field-symbol appearance?

Read only

sanjeeva_reddy9
Explorer
0 Likes
2,356

now changed . can you please check it now

Read only

matt
Active Contributor
0 Likes
2,356

Still not clear which program is which.

Read only

matt
Active Contributor
0 Likes
2,356

Attempting to use field symbols in this way is a bad idea, and totally pointless if both programs are Z, since you can change both, and so use more robust techniques.

You seem to have a fundamental misunderstanding though.You are trying to get the value of variable in program ytest_sanju_submit (an inner program), AFTER you've run it, from the outer program. The memory used by ytest_sanju_submit is no longer available when that program has finished execution. The field symbol technique is used to access the value of variables in the CALLING program from the CALLED program, when there's not really another way of sharing data . I'm not sure it even works with SUBMIT.

I suggest you spend some time reading up on ABAP memory.

Read only

retired_member
Product and Topic Expert
Product and Topic Expert
2,356

It does not work with SUBMIT.

https://help.sap.com/http.svc/rc/abapdocu_751_index_htm/7.51/en-US/index.htm?file=abapassign_mem_are...

the program "PROG" must be loaded into the same internal session as the current program

-> generally works only during external procedure calls

Read only

0 Likes
2,356

am just checking the functionality of field symbol by using this simple program.

if it works well then i go for the right one

thank you for your suggetions

Read only

matt
Active Contributor
0 Likes
2,356

Your test scenario is incorrectly constructed. You CANNOT do what you are trying to do.

Read only

retired_member
Product and Topic Expert
Product and Topic Expert
0 Likes
2,356

This line is apparently wrong:

lv_field = '(ytest_sanju_submit)-ls_makt)ls_makt'.

Read only

0 Likes
2,356

tried differently but still not getting sir. can you check it now

Read only

0 Likes
2,356

programs must be loaded into the same internal session ...

Read only

Sandra_Rossi
Active Contributor
0 Likes
2,356

SUBMIT AND RETURN starts a new internal mode. With field symbols, you can only access the variables from the same internal mode, so it just can't work.

You can only pass data via parameters (SUBMIT WITH), or using ABAP memory (EXPORT/IMPORT), or SAP memory (SET/GET PARAMETER), or any classic persistent layer (database table, file, etc.), or using ABAP channels. See "memory organization" in ABAP documentation to better understand the concepts.