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

Call a subroutine from a standard include program

ramiwal_dsilva
Participant
0 Likes
5,997

Hello experts,

I would like to know if there is a way i can call a subroutine located inside a standard include program from a Z-Function Module.

I have the below scenario

Z_FUNCTION_NAME

  PERFORM XYZ IN PROGRAM ('LXXXXXXX')

                   TABLES   LT_Tab1

                   USING    IM_p1 IM_p2 IM_p3 IM_p4 IM_p5

                   CHANGING LD_x1.

ENDFUNCTION.

Where LXXXXXX is a standard include program.

The Func Module throws no syntax errors and activates as normal.

But the issue arises when I do an EPC on the code..

It throws up an error

The program addressed by PERFORM must represent a compilation unit. The name of an include (LKWTFF0S)

is not possible. Specify the appropriate master program.

From what I understand, the called program must be of  type executable? How do I find the Master program?

It does not generate a where used list for the include.

I also saw that the include is a part of a larger function group.

Is there an alternative to do this?

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,864

LKWTFF0S is an include of function group and not an executable program so cannot be executed, replace it with the function group main program: SAPLKWTF (or its standard evolution/clone SAPLKWTF2 that shares some includes)

You could also try to include LKWTFF0S in your own function group, but you may then miss some declaration from standard function group globa area/top include.

Regards,

Raymond

4 REPLIES 4
Read only

Former Member
0 Likes
2,864

Hi Ramiwal,

I've done this using standard include programs but never with function modules (SE37) nor have  i seen it done using a se37 FM. Do you have the ability to create a se38 executable program and put your code there and then call that program?

Here is an example i've done in a tax procedure before

SE38 Include Program XXXX

PERFORM change_kwert(zcalculate) TABLES xkomv USING v_zssa_kbetr CHANGING xkwert.


SE38 executable Program zcalculate

FORM change_kwert TABLES xkomv STRUCTURE komv USING v_zssa_kbetr CHANGING xkwert.

....

Hope this helps,

Geoffery


Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,865

LKWTFF0S is an include of function group and not an executable program so cannot be executed, replace it with the function group main program: SAPLKWTF (or its standard evolution/clone SAPLKWTF2 that shares some includes)

You could also try to include LKWTFF0S in your own function group, but you may then miss some declaration from standard function group globa area/top include.

Regards,

Raymond

Read only

0 Likes
2,864

I agree with Raymond. You should always use the main program for function group and here in your case it is SAPLKWTF. Also before accessing the sub routine of another program you should declare the variables of same data type which you are passing to the sub routine from another program.

Please find the below code which you are looking:

*** Please note you can declare the variabels either at top include of your z- function group or in the existing function module locally based on your requirement

               data: lt_tab1 type TABLE OF RESBD,

                        IM_p1 type  AFKO-AUFNR,

                        im_p2  type  AFKO-AUFLD,

                        im_p3 type  AFKO-STLBEZ,

                        im_p4 type  AFKO-CUOBJ,

                        im_p5 type  COTPL-CLASS,

                        LD_x1 type SYST_SUBRC.

perform INIT_BOM IN PROGRAM ('SAPLKWTF') TABLES   LT_Tab1

                    USING    IM_p1 IM_p2 IM_p3 IM_p4 IM_p5

                    CHANGING LD_x1.


Hope it helps.


Thanks and best regards,

Gopi Akkapeddi

Read only

0 Likes
2,864

Thank you Raymond and Goppi,

I replaced the include with the main program SAPLKWTF.

Unfortunately, I do not have adequate data to test this. But the good news is, the EPC/ATC program checks are all positive now.

I will test this on Monday and get back to you with the results.

How do we check the main program for a given include?