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

Scripts............!!

Former Member
0 Likes
981

Hi All

how to write a perform in the form editor and how to call that one in the print program of that particular form, is there any thing care to be taken when we write the form routine in the form editor. i want the exact syntax and i also had a doubt about the <b>in_tab</b> and <b>out_tab</b> that are the importing and exporting parameters. where do they get declared (in_tab and out_tab) an example with logic flow will help me a lot to get an understanding about it.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
954

create a subroutine in an include report...

then in the sapscript call the perform as follows

/: PERFORM <form> IN PROGRAM <prog>

/: USING &INVAR1&

/: USING &INVAR2&

......

/: CHANGING &OUTVAR1&

/: CHANGING &OUTVAR2&

......

/: ENDPERFORM

in the perform... you need to define in_tab and out_tab as internal tables..

in these tables you'l get field name and their value..

same way you need to populate the corresponding value of each field in the out_tab

7 REPLIES 7
Read only

Former Member
0 Likes
955

create a subroutine in an include report...

then in the sapscript call the perform as follows

/: PERFORM <form> IN PROGRAM <prog>

/: USING &INVAR1&

/: USING &INVAR2&

......

/: CHANGING &OUTVAR1&

/: CHANGING &OUTVAR2&

......

/: ENDPERFORM

in the perform... you need to define in_tab and out_tab as internal tables..

in these tables you'l get field name and their value..

same way you need to populate the corresponding value of each field in the out_tab

Read only

0 Likes
954

Hi sharayu

thanks for that and i would appreciate if explained me more clearly with a from that was written in the print program, with some coding in that..

Read only

0 Likes
954

code in the SAP Script

/: PERFORM add_no IN PROGRAM ztest

/: USING &FLD1&

/: USING &FLD2&

/: CHANGING &SUM&

/: ENDPERFORM

Code In ZTEST

FORM add_no

TABLES IN_TAB STRUCTURE ITCSY

OUT_TAB STRUCTURE ITCSY.

data : fld1 type i,

fl2 type i,

sum type i.

read table in_tab-name with key name = 'FLD1'.

move in_tab-value to fld1.

read table in_tab-name with key name = 'FLD2'.

move in_tab-value to fld2.

sum = fld1 + fld2.

read table out_tab-name with key name = 'SUM'.

move sum to out_tab-value.

*Modify OUT_TAB

ENDFORM.

Read only

Former Member
0 Likes
954

Hi Ram,

i think this code will tell u about how to use the in_tab and out_tab..

FORM ZGRTOTAL TABLES IN_PAR STRUCTURE ITCSY OUT_PAR STRUCTURE ITCSY.

CLEAR LIFNR1.

READ TABLE IN_PAR WITH KEY 'EKKO-LIFNR'.

LIFNR1 = IN_PAR-VALUE.

CLEAR EKORG1.

READ TABLE IN_PAR WITH KEY 'EKKO-EKORG'.

EKORG1 = IN_PAR-VALUE.

CLEAR WAERS1.

READ TABLE IN_PAR WITH KEY 'EKKO-WAERS'.

WAERS1 = IN_PAR-VALUE.

CLEAR EBELN1.

READ TABLE IN_PAR WITH KEY 'EKKO-EBELN'.

EBELN1 = IN_PAR-VALUE.

CLEAR: KNUMH1,

ZNETPR,

BEDAT1.

CLEAR INT_POITMS.

REFRESH INT_POITMS.

SELECT SINGLE * FROM EKKO

WHERE EBELN = EBELN1.

BEDAT1 = EKKO-BEDAT.

SELECT MENGE WERKS PSTYP MATNR EBELP

APPENDING CORRESPONDING FIELDS OF

TABLE INT_POITMS

FROM EKPO

WHERE EBELN = EBELN1

AND LOEKZ NE 'L'.

LOOP AT INT_POITMS.

IF INT_POITMS-PSTYP = '2'.

CLEAR: ZLIFNR1,

ZMATNR1.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = lifnr1

IMPORTING

OUTPUT = zlifnr1

.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = INT_POITMS-MATNR

IMPORTING

OUTPUT = zmatnr1

.

SELECT SINGLE * FROM A017

WHERE LIFNR = ZLIFNR1

AND MATNR = ZMATNR1

AND EKORG = EKORG1

AND ESOKZ = INT_POITMS-PSTYP

AND WERKS = INT_POITMS-WERKS

AND KAPPL = 'M'

AND KSCHL = 'PB00'

AND ( ( DATAB = BEDAT1 OR DATAB < BEDAT1 ) AND ( DATBI = BEDAT1 OR

DATBI > BEDAT1 ) ) .

IF SY-SUBRC = 0.

KNUMH1 = A017-KNUMH.

SELECT SINGLE * FROM KONP

WHERE KNUMH = KNUMH1

AND LOEVM_KO NE 'X'.

IF SY-SUBRC = 0.

ZNETPR = KONP-KBETR.

CLEAR: ZCONV,

MENGE2,

MENGEN.

    • ZCONV = KONP-KUMZA / KONP-KUMNE.

  • ZCONV = KONP-KUMNE / KONP-KUMZA.

  • MENGEN = INT_POITMS-MENGE / KONP-KPEIN.

  • MENGE2 = MENGEN * ZCONV.

  • INT_POITMS-NETWR = MENGE2 * ZNETPR.

INT_POITMS-NETWR = ( KONP-KUMNE * INT_POITMS-MENGE * ZNETPR ) / (

KONP-KUMZA * KONP-KPEIN ).

MODIFY INT_POITMS.

ENDIF.

ENDIF.

ENDIF.

CLEAR INT_POITMS.

ENDLOOP.

CLEAR GRTOTAL.

LOOP AT INT_POITMS.

GRTOTAL = GRTOTAL + INT_POITMS-NETWR.

ENDLOOP.

  • GRTOTAL = GRTOTAL + VT_ATOTAL.

CLEAR X_GRTOTAL.

WRITE GRTOTAL TO X_GRTOTAL CURRENCY WAERS1.

MOVE 'ZGRTOT' TO OUT_PAR-NAME.

MOVE X_GRTOTAL TO out_par-value.

APPEND OUT_PAR.

ENDFORM.

..........================================

as shrayu said u have to write this form name in the script editor by calling thru PERFORM with using and changing variables.

this is the code in SCRIPT Editor

DEFINE &ZGRTOT& := &SPACE&

PERFORM ZGRTOTAL IN PROGRAM ZGETPODTL_CON

USING &EKKO-LIFNR&

USING &EKKO-EKORG&

USING &EKKO-WAERS&

USING &EKKO-EBELN&

CHANGING &ZGRTOT&

ENDPERFORM

<Y2>&ZTOTALORDER&</>,,,,,,,,,,,,,,,,,,<Y2>&ZGRTOT&</>

Hope u got the solution...

thanks

Jegadesh

Read only

Former Member
0 Likes
954

hi,

use this in text editor to add any field in ur script

/: PERFORM <subroutine_name> IN PROGRAM <program_name>

/: USING &par1&

/: CHANGING &par2&

the code below is used to add field which displays amount in words , here we are passing amount field as input in perform from script editor and fetching the amount in words for this in program using perform in se38.

in abap editor

data : begin of it_input_table occurs 0.

INCLUDE STRUCTURE ITCSY.

data : end of it_input_table.

data :begin of it_output_table occurs 0.

INCLUDE STRUCTURE ITCSY.

data :end of it_output_table.

*DATA : W_FK LIKE KOMK-FKWRT.

data : w_fkwrt(255) type c.

data : w_word(255) type c.

data : W_AMT TYPE PC207-BETRG.

FORM AMT_WORDS tables input output.

IT_INPUT_TABLE[] = INPUT[].

IT_OUTPUT_TABLE[] = OUTPUT[].

READ TABLE it_input_table INDEX 1.

*w_fkwrt = it_input_table-value.

move it_input_table-value to w_fkwrt.

DO.

REPLACE ',' WITH ' ' into W_FKWRT.

IF SY-SUBRC NE 0.

EXIT.

ENDIF.

ENDDO.

CONDENSE W_FKWRT NO-GAPS.

MOVE W_FKWRT TO W_AMT.

CALL FUNCTION 'HR_IN_CHG_INR_WRDS'

EXPORTING

AMT_IN_NUM = W_AMT

IMPORTING

AMT_IN_WORDS = w_word

  • EXCEPTIONS

  • DATA_TYPE_MISMATCH = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*WRITE:/10 W_WORD.

it_output_table-name = 'WORD'.

MOVE w_word to it_output_table-value.

MODIFY it_output_table INDEX 1.

output[] = it_output_table[].

ENDFORM.

in script.

PERFORM AMT_WORDS in program <programname> using and changing as u need.

regards

siva

Read only

0 Likes
954

OK i have this scenario. can any body help me with this

i am getting a the delivery number from the likp so i want to use the same delivery number and i want to retrive the weight of the item from lips, so what is the logic to be added. i am sending you the whole description....

please help me in solving this as i am very new to the scripts.

b. Remove the carton ID & box ID from the print out, the line item should just print the total delivery quantity, do not split the printing by different box ID or carton ID.

i. Delivery Item= LIPS-POSNR

ii. Delivery Qty for Item = LIPSD-G_LFIMG= LIPSD-PIKMG

c. Add Total Boxes for each item, this should be a calculation field for each material HUMV4-MATNR, count how many handling unit VEKPVB-EXIDV has been used to pack the same material , output the total boxes for each delivery item.

d. Add Gross Weight for each item , retrieve data from LIPS-BRGEW

e. Add Net weight to the print out, below the gross weight – retrieve data from LIKP-NTGEW

f. For Net Weight & Gross Weight – all convert to KG before output on the print out

Read only

0 Likes
954

i want to change the gross weight along with units so how to do that with using the perform statement

let the gross weight is named as a symbol &gross_weight& in the form editor and the unit as &GROSS_WEIGHT_UNIT&

PERFORM set_textsymbol USING '&GROSS_WEIGHT&'

v_btgew.

PERFORM set_textsymbol USING '&GROSS_WEIGHT_UNIT&'

v_gewei.

i want to copy these vaules in to other variables and then get the gross weight to be changed to the desired values according to the logic.