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: 

How to read internal table other program (assign?)

Former Member
0 Kudos

Hello techies,

The problem >

I have 2 Sap standard programs A & B

I'm editing a userexit in program B but I need to read

data from program A that is also running.

While using the debugger, I can ask for the folowing

(A)internaltable

example : (SAPLMEPO)pot

this shows the content of internal table "pot" of the program "SAPLMEPO".

The question>

How can I copy the content of a table(ex. pot) in program "A"(ex. SAPLMEPO) to a internal table pot2 of program "B"?

Possible sollution (does not work in 5.0)

                          • CODE SAMPLE *************

    • Fields **

data: w_name type char50,"help field

w_recpot like ekpo."help structure

    • Internal tables **

data: Begin of it_pot2 occurs 0.

include structure it_pot2.

data: End of it_pot2

field-symbols <fs_pot> type any table.

w_structure_name = '(SAPLMEPO)pot'.

assign (w_structure_name) to <fs_pot>.

loop at <fs_pot> into w_recpot.

it_pot2 = w_recpot.

append it_pot2

Endloop.

                          • END CODE SAMPLE *************

Thanks in advance,

Frederik

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi again,

1. Simple.

2. In your case, u should use

<b>[]</b>

DATA : myitab LIKE TABLE OF t001 WITH HEADER LINE.

DATA : w_struct_name(100) TYPE c.

BREAK-POINT.

FIELD-SYMBOLS <fs_pot> TYPE ANY TABLE.

<b> w_struct_name = '(ZAM_TEMP0)ITAB[]'.</b>

ASSIGN (w_struct_name) TO <fs_pot>.

3. No need to use Loop etc.

4. *----


In your case

                          • CODE SAMPLE *************

    • Fields **

data: w_name type char50,"help field

w_recpot like ekpo."help structure

    • Internal tables **

data: Begin of it_pot2 occurs 0.

include structure it_pot2.

data: End of it_pot2

field-symbols <fs_pot> type any table.

w_structure_name = '<b>(SAPLMEPO)POT[]</b>'.

assign (w_structure_name) to <fs_pot>.

*----


NOT REQUIRED

*loop at <fs_pot> into w_recpot.

*it_pot2 = w_recpot.

*append it_pot2

*Endloop.

                          • END CODE SAMPLE *************

regards,

amit m.

7 REPLIES 7

Former Member
0 Kudos

Hi Frederik,

1. If the programs A and B

are currently in memory

(ie, A has called b, and b has user-exit)

ONLY THEN

we can access variables of A, in user-exit.

2. But if program A

is not in memory

(ie. its not called anywhere in the sequence, )

then OFFLINE

nothing can be done !

regards,

amit m.

0 Kudos

Or use import / export statement!

thx for reward!

Stephan

0 Kudos

**** should read topic completely

Amit is right

cheerz

Former Member
0 Kudos

Hi,

very simple...

Try to create common data are with the same name in both program with this statement!

Content should be kept

DATA - Defining Common Data Areas 


Basic form 
DATA: BEGIN OF COMMON PART c, 
        ... 
      END   OF COMMON PART. 



This statement is not allowed in an ABAP Objects context. See Shared data areas not allowed. 

Effect 
Defines one or more common data area in programs that are connected by external PERFORM calls. If there is only one common data area, you can omit the name c. You may have a single, unnamed COMMON are or one or more named COMMON areas. Named COMMON areas are assigned to each other by name. The construction of the data area must be the same in both the calling and the called program (otherwise the program terminates at runtime with a corresponding message). 
You must specify the name of a common data area as a direct value, without inverted commas. 



Notes 
Table work areas automatically belong to the common data area. 



The area created using COMMON is usually defined by a shared INCLUDE STRUCTURE definiert. Occasionally you might use the technique of an INCLUDE program containing just the definition of the COMMON PARTs. 



Field symbols cannot belong to a common data area, even if the FIELD-SYMBOLS statement comes between the DATA BEGIN OF COMMON PART and DATA END OF COMMON PART statements. 


Additional help 
Interface Work Areas 

Former Member
0 Kudos

Hi again,

1. Simple.

2. In your case, u should use

<b>[]</b>

DATA : myitab LIKE TABLE OF t001 WITH HEADER LINE.

DATA : w_struct_name(100) TYPE c.

BREAK-POINT.

FIELD-SYMBOLS <fs_pot> TYPE ANY TABLE.

<b> w_struct_name = '(ZAM_TEMP0)ITAB[]'.</b>

ASSIGN (w_struct_name) TO <fs_pot>.

3. No need to use Loop etc.

4. *----


In your case

                          • CODE SAMPLE *************

    • Fields **

data: w_name type char50,"help field

w_recpot like ekpo."help structure

    • Internal tables **

data: Begin of it_pot2 occurs 0.

include structure it_pot2.

data: End of it_pot2

field-symbols <fs_pot> type any table.

w_structure_name = '<b>(SAPLMEPO)POT[]</b>'.

assign (w_structure_name) to <fs_pot>.

*----


NOT REQUIRED

*loop at <fs_pot> into w_recpot.

*it_pot2 = w_recpot.

*append it_pot2

*Endloop.

                          • END CODE SAMPLE *************

regards,

amit m.

Former Member
0 Kudos

Hello Frederik,

try this...

    • Fields **

data: w_name type char50,"help field

w_recpot like ekpo."help structure

    • Internal tables **

data: Begin of it_pot2 occurs 0.

include structure it_pot2.

data: End of it_pot2

field-symbols <fs_pot> type any table.

w_structure_name = '(SAPLMEPO)pot[]'.<-changed

assign (w_structure_name) to <fs_pot>.

loop at <fs_pot> into w_recpot.

it_pot2 = w_recpot.

append it_pot2

Endloop.

instead of loop .. endloop use

it_pot2[] = <fs_pot>[].

this should work.

0 Kudos

Hello,

I must thank you all for the quick responses.

Indeed the error was

w_structure_name = '(SAPLMEPO)pot[]'.

By adding the [] to the code it can look for tables and not only structures.

Best Regards,

Frederik