‎2006 May 02 11:06 AM
Hi Experts,
I have a standard SAP program that calls a standard SAP script.
I need to introduce a sub-routine from the SAP script which will reside inside a custom program sending a workarea into it and getting back another workarea with a different structure from the first and then use the resultant workarea in the SAP script to display the results.
This is done since it doesn't need a change in the SAP standard program. Anyway my SAP script will undergo a change which i can afford.
For example consider the following :
<b>This is my code bit in the program calling an element in the SAP script.</b>
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = <selement>
window = <swindow>
function = <sfunction>
EXCEPTIONS
element = 01
function = 02
type = 03
unopened = 04
unstarted = 05
window = 06.
<b>The Element in the SAP script is as follows:</b>
/E <selement>
T4 &struc1-field1& &struc1-field2& &struc1-field3&
Instead of the above I need to send the struc1 to a sub-routine and then get back another structure
<b>Something like this.</b>
/E <selement>
: perform <subroutine_name> using struc1 struc2
T4 &struc2-field1& &struc2-field2& &struc2-field3&
&struc2-field4&
<i>note : struc1 and struc2 are of different structures
The sub routine will reside in the custom program</i>
Now my question is, where to define my structure stru2(whether in the custom program or in the Standard program).
Is there any other way to implement the same without disturbing the SAP standard program?
‎2006 May 03 6:38 AM
Hi Arul,
1. The points system seems to be working/active now.
2. U may pls award appropriate points.
Thanks in advance.
regards,
amit m.
‎2006 May 02 11:11 AM
YOu can use the define statement to declare your variables in the text elements editor itself.
eg:
/: DEFINE &BARCODE& := '&SPACE(12)&'
/* DEFINE &BARCV& := '&KARTE-BARCV&' (REMOVED FOR INUSE BARCODE)
/: DEFINE &BARC6& := '&KARTE-BARC6&'
/: PERFORM GET_BARCODE IN PROGRAM ZVXR0076
/* USING &BARCV&
/: USING &BARC6&
/: CHANGING &BARCODE&
/: ENDPERFORM
Regards,
Ravi
‎2006 May 02 11:15 AM
Thanks Ravi,
But these are single values can I pass a structure and get back structure where both the structures are of different types?
‎2006 May 02 11:23 AM
HI Jothi,
May be what you can try is to define a variable of sufficient length and then take offset from that structure to get differen fields in that long field.
eg DEFINE &structure& := '&SPACE(50)&'
or use as many variable as the nimber of fields in that structure.
Regards,
Ravi
‎2006 May 02 11:32 AM
Hi arul,
1. while calling subroutines from sapscripts,
there is a special technique,
which has got its own limitations.
2.
FORM abc
TABLES
in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
ENDFORM.
3. The perform in se38 program should be of the
above format only.
4. We cannot pass internal tables.
5. Rather we need to pass
VARIABLE NAME
VARIABLE VALUE
(see the structure of itcsy in se11)
6. In this form, we have to read
the internal table in_tab
to capture the variable name and its value.
7. Similary, to return the values,
we have to put one record (for each variable)
in out_tab.
regards,
amit m.
‎2006 May 02 11:55 AM
Hi Amit,
Your answers seems to be feasible. I have a couple of clarrifications to be made.
1. How should my perform statement look like in the SAP script.
2. How should I use the fields in the resultant structure in the SAP script.
‎2006 May 02 11:57 AM
Hi again,
1. How should my perform statement look like in the SAP script.
PERFORM ROUTINNAME IN PROGRAM ZPROG
USING &ITAB-F1&
USING &ITAB-F2&
USING &ITAB-F3&
CHANGING
USING &F4&
USING &F5&
ENDPERFORM.
2. How should I use the fields in the resultant structure in the SAP script.
Just use the variable name
&F4&
(u can give any name and use it back)
regards,
amit m.
‎2006 May 02 12:03 PM
Hi Amit,
My second doubt is clarrified now.
But I cannot understand your answer to teh first.
1. should F4 and F5 be declared somewhere?
and
2. why there are "USING" pharses(2) after the "CHANGING"
Regards,
Arul Jothi.
‎2006 May 02 12:45 PM
Hi again,
1. should F4 and F5 be declared somewhere?
Not necessary.
In fact, not required.
Just give ANY Variable name.
2. why there are "USING" pharses(2) after the "CHANGING"
Well, thats not required.
In fact, do not use it. Its wrong !
regards,
amit m.
‎2006 May 02 1:12 PM
Hi Amit,
Thanks a lot for your patient reply.
I am tring to reward you points but I cannot see the radio buttons along side of your reply.
what should I do now.
Arul Jothi.
‎2006 May 02 2:02 PM
Hi again,
1. Probably the points system may not
be working, temporarily.
2. If it get working again,
at that point u may reward the points.
Thanks in advance.
regards,
amit m.
‎2006 May 03 6:38 AM
Hi Arul,
1. The points system seems to be working/active now.
2. U may pls award appropriate points.
Thanks in advance.
regards,
amit m.