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: 

Runtime values of internal table

0 Kudos

Hi,

Is it possible to get the runtime value of all the internal tables used in a program ?


Let the parent program is ZPGM_PARENT . From this parent program, we are calling the child program ZPGM_CHILD using SUBMIT and RETURN statement. Is there any function module which will return the internal tables used in ZPGM_CHILD with its runtime values ?

Thanks,

Rohith

24 REPLIES 24

PeterJonker
Active Contributor
0 Kudos

I think you will need to adjust the program ZPGM_CHILD with statements to export the internal tables and the program ZPGM_Parent then can read these exported tables with import statement.s

Without adjusting the programs I don't think it is possible

0 Kudos

Hi Jonker,

Thanks for your responds.

I dont want to disturb the existing code.

In my requirement, ZPGM_CHILD name will be dynamic.

Any other solution to this ? If any function module serve this ?

Former Member
0 Kudos

Hi Rohith,

Am i correct in my interpretation of your question that you want to get a result set (in this case a ITAB) from the child program once the child program has finished running?

If so i would recommend using the EXPORT and IMPORT methods as well as the SET and GET PARAMETER statements in both programs. This is how i have done it in pricing procedures before when passing tax information between different tax routines.

Here is a page that goes more into what i'm referring to Passing Data Between Programs - ABAP Programming (BC-ABA) - SAP Library

Hope this helps,

Geoffery

raymond_giuseppi
Active Contributor
0 Kudos

As already written, the called program must save its data in memory or a persistent cluster of data if you want caller to get this information. Read documentation of EXPORT/IMPORT statement and online documentation on SAP Memory.

Hint: Some tools, as ALV, also have this option integrated (perform some search on class cl_salv_bs_runtime_info)

Regards,

Raymond

0 Kudos

Thanks Raymond.


I cannot adjust the code of child program as the program of child program will be dynamic.

0 Kudos

I'm pretty sure this is obsolete, but it might help in this case.

Press F1 on BEGIN OF COMMON AREA.

Rob

0 Kudos

Thanks Rob.


If I'm correct this is related to shared memory. ZPGM_CHILD has to push the values to shared-memory area, right ?


Will we get the values without disturbing the code ?

0 Kudos

OK - it should be BEGIN OF COMMON PART, and it is definitely obsolete.

You'll have to check the documentation to see if it suits your purposes.

But you do have to make some minor changes to both programs - putting all of the data you need into the COMMON PART.

Rob

0 Kudos

Thanks Rob.

Oh we need to push all the data to shared memory. It cannot be done. Why because, Child program name will not be the same always. It will vary during the execution of the parent program.

0 Kudos

I don't think it matters. You just have to ensure that all of the programs have the COMMON PART. I don't think all of the COMMON PARTs have to be the same either.

I don't know of any way to do directly what you are trying to do.

Rob

juan_suros
Contributor
0 Kudos

I think you can solve this program by organizing your code to place all iTabs in program ZPGM_PARENT, writing program ZPGM_CHILD to modify these iTabs thru references, and then using PERFORM to call the child program.

Debug the following programs. SUBMIT does not work, but PERFORM works fine.

REPORT zpgm_parent.

LOAD-OF-PROGRAM.

  DATA: t_list TYPE stringtab.

  FIELD-SYMBOLS: <s> TYPE string.

START-OF-SELECTION.

  SUBMIT zpgm_child AND RETURN.

  PERFORM fill_itab IN PROGRAM zpgm_child IF FOUND.

 

END-OF-SELECTION.

  LOOP AT t_list ASSIGNING <s>.

    WRITE: /01 <s>.

  ENDLOOP.

*"

REPORT zpgm_child.

LOAD-OF-PROGRAM.

  DATA: ref TYPE string.

  FIELD-SYMBOLS: <t_list> TYPE stringtab.

  FIELD-SYMBOLS: <s> TYPE string.

  ref = |(ZPGM_PARENT)T_LIST[]|.

  ASSIGN (ref) TO <t_list>.

*&---------------------------------------------------------------------*

*&      Form fill_itab

*&---------------------------------------------------------------------*

FORM fill_itab.

  CHECK: <t_list> IS ASSIGNED.

  APPEND INITIAL LINE TO <t_list> ASSIGNING <s>.

  <s> = |Hello World|.

UNASSIGN: <s>.

ENDFORM.                    "fill_itab

START-OF-SELECTION.

  PERFORM fill_itab.

*"

0 Kudos

Thanks Juan,

What i try to achieve is ZPGM_PARENT will call another proram (say: ZPGM_CHILD) dynamically.

Child program name will be different at every execution. It will be like an input parameter.

REPORT ZPGM_PARENT

parameter: pa_pgm(100).

start-of-selection.

submit pa_pgm and return.

end-of-selection.

Thanks.

0 Kudos

Rohith,

Use of the SUBMIT command will make this achievement difficult. Submit creates a different programming session for the new program.

I suggest using PERFORM ... IN PROGRAM because the new program will be created in the same memory session.

Juan

0 Kudos

Is there any function module which will accept the program name and variant name and returns all the run time variables with run time data ?

0 Kudos

Hi Rohith,

No such FM exists to my knowledge nor should it have to exist since data can easily be transferred with code changes.

One thing i have failed to understand in your requirements through all of these posts is why are you not able to modify the called program? You have mentioned that the program names could change which is fine you can code your parent program to account for that but that does not change the fact that the child programs will still have to be changed to return a result regardless of method described by the different users in this thread.

If you could let us know how this child program determination works and how the child program was created we may be able to give better guidance.

Geoffery

0 Kudos

A very good question. I don't understand how a child program can be both dynamically generated and unchangeable.

0 Kudos

Hi Geoffery,

Thank you for your helping mentality. Here is the scenario.

REPORT ZPGM_PARENT.

Parameter : pa_child_pgm type char(100).

Start-of-selection.

SUBMIT pa_child_pgm AND RETURN.

end-of-selection.


I can execute ZPGM_PARENT with different child program name, since this is an input parameter. So how is it possible to change the code of child program ? Child program name is known only at the run time of ZPGM_PARENT.

I hope requirement is stated well

0 Kudos

Hi Rohith,

I may have been a little vague when i was talking about changing the child program. I was not referring to changing it during the runtime of ZPGM_PARENT but changing the actual se38 code before hand.

Now based on the code sample you provided you are taking the child program name (pa_child_pgm) as a parameter of ZPGM_PARENT. How is pa_child_pgm populated, is it populated in a static variant or is there a 3rd program that populates that variable?

Also just to make sure the program name passed in pa_child_pgm already exists in se38 correct? As long as the child program name (no matter how many different programs there are) exists in se38 you can extend the program via any fashion mentioned in this thread so far to use the same memory variable names and then just make 1 change to ZPGM_PARENT to get the result set.

Geoffery

0 Kudos

Hi Geoffery,

Changing the actual code of (pa_child_pgm) ?

pa-child_pgm is an input parameter of ZPGM_PARENT. I can do whatever changes i need in ZPGM_PARENT. But how would i do the change in code of (pa_child_pgm) ?

User can enter any program name as the input of ZPGM_PARENT. That will be known only when we execute the ZPGM_PARENT.

Rohith.

0 Kudos

Hi Rohith,

Now i'm starting to get a better understanding of your program, this is not a program that has a static number of programs stored in variants that it can call but can vary depending on what a end user wants to input manually.

This is a very very difficult challenge to have, now i need to ask is the sole purpose of zpgm_parent just to display some sort of runtime data from the child program if it can get it?

If so then i hate to say but you may not have a way of doing this if users can call any program they want. All of the comments thus far have to my knowledge required code change of the child program to return results.

Geoffery

0 Kudos

But WHY do you want to do this ? Why dont you call the child programm directly ?

I am confused about your motives. It looks to me you are just putting a hypothetical case here. I don't see why you want to submit another program like this.

There must be a reason why you want to do it like this. There is NO WAY that you can get the internal table values of a program you call like this without changing the child program. Unless you want to see the result of your child program, but then you can call the child program directly or use the exporting list to memory statement

You need to tell us WHY otherwise it is impossible to help you.

0 Kudos

And if a function module would exist, which runtime data you want to fetch ? The data just after the start of the programm, the data after your first select, or if there are more select statements the data after the second select? The data after the child programm has deleted some stuff or after it has manipulated the data in any other way ?

Basically, in which moment in time of execution you want to know the runtime data, halfway the loop ?

This is, to my opinion, a very silly request.

0 Kudos

Hi Rohit,

This way seems to work.

Have a custom DDIC table which stores the data in the internal tables of child program. Once the program returned to parent program fetch the data from the custom DDIC table.

Before the parent program ends clear all the data in the Custom table.

Insert Delete statements would help in this.

This could help you instead on export and import.

Regards,

Veera

0 Kudos

That DDIC table needs to be filled with the internal table values . How do we get those values ?