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

Doubt

Former Member
0 Likes
674

Hi Friends,

Can anyone explain me the following code written for the Sapscript. The First part is written SE38 and next part in SE71 - Text Element layout.

I would like to know the following.

1. How the perform works in Text Element Layout.

2. What is Intab and Outtab.

3. What is table structure ITCSY.

4. What is &CHANGING&.

5. What is &USING&.

6. How is the code written in SE38 (Print program) links with the Text Element layout part.

7. Why perform is used in Text Element layout instead of fetching the necessary data in an internal table and to use the same.

-


<< SE-38 >>

&----


*& Form ZSEL_FIELD

&----


  • text

&----


  • -->INTAB text

  • -->OUTAB1 text

&----


FORM ZSEL_FIELD TABLES INTAB STRUCTURE ITCSY

OUTAB1 STRUCTURE ITCSY.

READ TABLE INTAB INDEX 1.

SELECT SINGLE * FROM VBRK WHERE VBELN = INTAB-VALUE.

READ TABLE INTAB INDEX 2.

SELECT * FROM KONV INTO CORRESPONDING FIELDS OF TABLE ITAB1

WHERE KNUMV = VBRK-KNUMV

AND KPOSN = INTAB-VALUE.

LOOP AT ITAB1.

IF ITAB1-KSCHL = 'ZFPR'.

WA_ZFPR = ITAB1-KWERT.

ENDIF.

IF ITAB1-KSCHL = 'ZABT'.

WA_ZABT = ITAB1-KWERT.

WA_RABT = ITAB1-KBETR.

WA_RABT = WA_RABT / 10.

ENDIF.

IF ITAB1-KSCHL = 'JECS'.

WA_JECS = ITAB1-KWERT.

ENDIF.

ENDLOOP.

WA_ZFPR1 = WA_ZFPR.

WA_ZFPR2 = WA_ZFPR1.

CONDENSE WA_ZFPR2 NO-GAPS.

CALL FUNCTION 'Z_CHAR_CURR_CONVERSION'

EXPORTING

AMOUNT = WA_ZFPR2

IMPORTING

AMOUNT1 = WA_ZFPR2.

CONDENSE WA_ZFPR2 NO-GAPS.

READ TABLE OUTAB1 INDEX 1.

MOVE WA_ZFPR2 TO OUTAB1-VALUE.

MODIFY OUTAB1 INDEX 1.

WA_ZABT1 = WA_ZABT.

WA_ZABT2 = WA_ZABT1.

CONDENSE WA_ZABT2 NO-GAPS.

CALL FUNCTION 'Z_CHAR_CURR_CONVERSION'

EXPORTING

AMOUNT = WA_ZABT2

IMPORTING

AMOUNT1 = WA_ZABT2.

CONDENSE WA_ZABT2 NO-GAPS.

READ TABLE OUTAB1 INDEX 2.

MOVE WA_ZABT2 TO OUTAB1-VALUE.

MODIFY OUTAB1 INDEX 2.

READ TABLE OUTAB1 INDEX 3.

WA_JECS1 = WA_JECS.

MOVE WA_JECS1 TO OUTAB1-VALUE.

MODIFY OUTAB1 INDEX 3.

READ TABLE OUTAB1 INDEX 4.

WA_RABT1 = WA_RABT.

MOVE WA_RABT1 TO OUTAB1-VALUE.

MODIFY OUTAB1 INDEX 4.

CLEAR ITAB1.

REFRESH ITAB1.

ENDFORM. " ZSEL_FIELD

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

<< SE71 - TEXT ELEMENT LAYOUT >>

/: PERFORM ZSEL_FIELD IN PROGRAM ZJ1I_ADD

/: USING &J_1IEXCHDR-RDOC&

/: USING &J_1IEXCDTL-ZEILE&

/: CHANGING &TEXT1&

/: CHANGING &TEXT2&

/: CHANGING &TEXT3&

/: CHANGING &TEXT4&

/: ENDPERFORM

-


Kindly explain the above.

Thanks in advance,

Mark K

I1 &J_1IEXCDTL-ZEILE&,,&J_1IEXCDTL-MATNR&,,&J_1IEXCDTL-MENGE&,,

I1 &J_1IEXCDTL-MEINS&,,&TEXT1&,,&TEXT2&,,&J_1IEXCDTL- EXBAS(16.2R)&,,

I1 &J_1IEXCDTL-EXBED(16.2R)&,,&J_1IEXCDTL-ECS(13.2R)&

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
625

hi,

here is the scenario where you need to write some FORMS in a Zprogram to fetch some values & get them in the script and finally print them on the layout.

for example : we have a standard layout & driver program for PO . MEDRUCK is the layout name & some SAP* will be the driver program name. suppose for your client, he need some more details (like VENDOR country for example also needs to print on the layout,assume its not printing now).

what you have to do is

1. copy the layout to a new Z layout.

2. then your task would be printing of VENDOR COUNTRY on the layout. for that instead of changing the standard driver program or copying it to a new Z program for this simple addition, we will make use of PERFORM & FORM given by script.

WE WILL write a Z program and write a FORM which will take VENDOR NO as INPUT & fetch its country from LFA1 & sends back the VENDOR COUNTRY.

we will then call that form which is available in the program in the layout using PERFORM control command.

in that call,

USING : we use for sending the values from script to the program,(in our case, to fetch vendor country we need to send vendor no).

CHANGING is the parameters whose value will be populated in that form & comes as output to the script.

2. Intab and Outtab

these both having same structure of ITCSY.

this ITCSY having 2 fields NAME & VALUE.

i mean, if you are sending VENDOR NO & FETCHING VENDOR COUNTRY this would as :

your &LFA1-LIFNR& Will be the NAME

and 100 is the value you are sending .

in the similar way,

if you want to modify the outtab for vendor country.

you have to say

modify outtab where name = 'vend_country'.

regards

srikanth

4 REPLIES 4
Read only

Former Member
0 Likes
625

:PERFORM get_date IN PROGRAM zreport

/:USING &SALESORDER&

/:CHANGING &S_DATE&

/:ENDPERFORM

Now you can print S_DATE.

Write this code in the new ABAP program would be

REPORT zreport.

FORM get_date TABLES in_tab STRUCTURE ITCSY

out_tab STRUCTURE ITCSY .

READ TABLE in_tab INDEX 1.

SELECT some_date FROM ztab

WHERE salesorder = in_tab-value.

IF sy-subrc EQ 0.

READ TABLE out-tab INDEX 1.

MOVE ztab-somedate TO out_tab-value

MODIFY out_tab INDEX 1.

ENDIF.

ENDFORM.

Read only

Former Member
0 Likes
626

hi,

here is the scenario where you need to write some FORMS in a Zprogram to fetch some values & get them in the script and finally print them on the layout.

for example : we have a standard layout & driver program for PO . MEDRUCK is the layout name & some SAP* will be the driver program name. suppose for your client, he need some more details (like VENDOR country for example also needs to print on the layout,assume its not printing now).

what you have to do is

1. copy the layout to a new Z layout.

2. then your task would be printing of VENDOR COUNTRY on the layout. for that instead of changing the standard driver program or copying it to a new Z program for this simple addition, we will make use of PERFORM & FORM given by script.

WE WILL write a Z program and write a FORM which will take VENDOR NO as INPUT & fetch its country from LFA1 & sends back the VENDOR COUNTRY.

we will then call that form which is available in the program in the layout using PERFORM control command.

in that call,

USING : we use for sending the values from script to the program,(in our case, to fetch vendor country we need to send vendor no).

CHANGING is the parameters whose value will be populated in that form & comes as output to the script.

2. Intab and Outtab

these both having same structure of ITCSY.

this ITCSY having 2 fields NAME & VALUE.

i mean, if you are sending VENDOR NO & FETCHING VENDOR COUNTRY this would as :

your &LFA1-LIFNR& Will be the NAME

and 100 is the value you are sending .

in the similar way,

if you want to modify the outtab for vendor country.

you have to say

modify outtab where name = 'vend_country'.

regards

srikanth

Read only

Former Member
0 Likes
625

Hi MARK,

1.In the text element area you have just to write the perform.Form will be written in the print program.The output field value will be returned to the SAPSCRIPT.

2.Intab and outtab is the same as using and changing that you use in the normal perform.

3. table structure ITCSY data structure for declaring intab and outtab.

4.&using& is field value that you are using from the FORM.

5.&changing& is field value that you are changing in the Print program form.

6.In the form with the perform you have written the Print program also from there it is linking the perform with the form iin the priint program.

Regards,

Mukesh Kumar

Read only

venkat_o
Active Contributor
0 Likes
625

Hi Mark,

<b>

2. What is Intab and Outtab.</b>

u can give any name for those internal tables only difference is First table INTAB contains whatever give in under USING statement &J_1IEXCHDR-RDOC& &J_1IEXCDTL-ZEILE&

fields without & thier values at runtime are stored .

Second table OUTTAB contains whatever give in under CHANGING statement /: CHANGING &TEXT1& &TEXT2& &TEXT3&

&TEXT4& fields without &thier values at runtime are stored .

<b>3. What is table structure ITCSY.</b>

ITCSY structure has 2 fields

NAME=>CHAR=>130=>Name of a program symbol (w/o &)

VALUE=>CHAR=>255=>Text symbol value

<b>4. What is &CHANGING&.

5. What is &USING&.</b>

Using &USING& fields value we change OUTTAB values those are automatically reflected in PERFORM statement under CHANGING

6.

U have to write in SUbroutine .Only thing is Use the existing values using INTAB and also u can use SELECT quiries to get what u want .Change the INTAB table .

<b>Thanks,

Venkat.O</b><b></b>