cancel
Showing results for 
Search instead for 
Did you mean: 

how to map values in_par and out_par in script and program

Former Member
0 Kudos

hii experts,

here my code....

perfrom in FORM is...

PERFORM GET_VENDOR_ADDRESS IN PROGRAM ZRVADOR2TEST

USING &NAME1&

USING &NAME2&

USING &STRAS&

.

.

.

.

.

.

.

CHANGING &NAME1_1&

CHANGING &NAME2_2&

CHANGING &STRAS_1&

.

.

.

.

.

.

.

IN PROGRAM................

form GET_VENDOR_ADDRESS tables in_par structure itcsy

out_par structure itcsy.

types: begin of tp_ven_address,

lifnr type lfa1-lifnr,

adrnr type lfa1-adrnr,

name1 type lfa1-name1,

name2 type lfa1-name2,

stras type lfa1-stras,

ort01 type lfa1-ort01,

ort02 type lfa1-ort02,

pstlz type lfa1-pstlz,

regio type lfa1-regio,

end of tp_ven_address.

data: it_ven_address type table of tp_ven_address with header line.

data: wa_ven_address type tp_ven_address.

DATA L_MFRNR TYPE MARA-MFRNR.

IF VBDKA-DWERK = '97' AND VBDKA-ZZSHPMET = '1PC'.

READ TABLE TVBDPA WITH KEY VBELN_VANG = VBDKA-VBELN.

SELECT SINGLE MFRNR FROM MARA INTO L_MFRNR WHERE MATNR = TVBDPA-MATNR.

SELECT LIFNR ADRNR NAME1 NAME2 STRAS ORT01 ORT02 PSTLZ REGIO

FROM LFA1

INTO CORRESPONDING FIELDS OF TABLE it_ven_address

WHERE ADRNR = VBDKA-ADRNR.

ENDIF.

*read table in_par with key 'NAME1'.

*check sy-subrc = 0.

*

*

*

*loop at it_ven_address into wa_ven_address.

*

*in_par-value = wa_ven_address-name1.

*in_par-value = wa_ven_address-stras.

*append in_par.

*endloop.

*

*read table in_par with key 'NAME1_1'.

*check sy-subrc = 0.

endform.

my requierement is how we pass value from internal table it_ven_address to out_par.....

please provide me the suitable code.

thanks

RC

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Try like this.

form GET_VENDOR_ADDRESS tables in_par structure itcsy

out_par structure itcsy.

types: begin of tp_ven_address,

lifnr type lfa1-lifnr,

adrnr type lfa1-adrnr,

name1 type lfa1-name1,

name2 type lfa1-name2,

stras type lfa1-stras,

ort01 type lfa1-ort01,

ort02 type lfa1-ort02,

pstlz type lfa1-pstlz,

regio type lfa1-regio,

end of tp_ven_address.

data: it_ven_address type table of tp_ven_address with header line.

data: wa_ven_address type tp_ven_address.

DATA L_MFRNR TYPE MARA-MFRNR.

IF VBDKA-DWERK = '97' AND VBDKA-ZZSHPMET = '1PC'.

READ TABLE TVBDPA WITH KEY VBELN_VANG = VBDKA-VBELN.

SELECT SINGLE MFRNR FROM MARA INTO L_MFRNR WHERE MATNR = TVBDPA-MATNR.

SELECT SINGLE LIFNR ADRNR NAME1 NAME2 STRAS ORT01 ORT02 PSTLZ REGIO

FROM LFA1

INTO (lifnr,adrnr,name1,name2,stras,ort01,ort0,pstlz,regio)

WHERE ADRNR = VBDKA-ADRNR.

ENDIF.

READ TABLE out_par WITH KEY NAME = 'NAME1_1'. .

IF SY-SUBRC EQ 0.

OUT_TAB-VALUE = LIFNR.

MODIFY out_par INDEX SY-TABIX.

ENDIF.

READ TABLE out_par WITH KEY NAME = 'NAME2_2'. .

IF SY-SUBRC EQ 0.

OUT_TAB-VALUE = ADRNR .

MODIFY out_par INDEX SY-TABIX.

ENDIF.

and soon

former_member585060
Active Contributor
0 Kudos

Hi,

Be clear for fetching data LFA1, you pass the value from SAPScript a value in USING parameter and based on that get the address values from LFA1 table.

Ex:

For my code i am getting company code address details based on BUKRS and SPRAS from SAPScript.

SAPScript

/:PERFORM GET_COMCODE IN PROGRAM ZM_RFQ_REJECTION

/:USING &EKKO-BUKRS&

/:USING &EKKO-SPRAS&

/:CHANGING &SADR-NAME1&

/:CHANGING &SADR-NAME2&

/:CHANGING &SADR-NAME3&

/:CHANGING &SADR-PSTLZ&

/:CHANGING &SADR-NAME4&

/:ENDPERFORM

Subroutine.

FORM get_comcode TABLES in_tab STRUCTURE itcsy

out_tab STRUCTURE itcsy.

DATA : w_bukrs TYPE ekko-bukrs, "Company code

w_name1 TYPE t001-butxt, "Company name

w_rcomp TYPE t001-rcomp, "

w_stret TYPE t880-stret, "Street address

w_pstlc TYPE t880-pstlc, "Postal code

w_ort01 TYPE t001-ort01, "City

w_city TYPE t880-city, "City

w_landx TYPE t005t-landx, "Country name

w_land1 TYPE t001-land1. "Country code

READ TABLE in_tab INDEX 1.

w_bukrs = in_tab-value.

READ TABLE in_tab INDEX 2.

w_spras = in_tab-value.

SELECT butxt

rcomp

land1 FROM t001 INTO (w_name1, w_rcomp, w_land1)

WHERE bukrs = w_bukrs.

SELECT SINGLE stret

pstlc

city FROM t880 INTO (w_stret, w_pstlc, w_city)

WHERE rcomp = w_rcomp.

SELECT SINGLE landx FROM t005t INTO w_landx

WHERE land1 = w_land1

AND spras = w_spras.

ENDSELECT.

READ TABLE out_tab INDEX 1.

MOVE w_name1 TO out_tab-value.

MODIFY out_tab INDEX sy-tabix.

READ TABLE out_tab INDEX 2.

MOVE w_stret TO out_tab-value.

MODIFY out_tab INDEX sy-tabix.

READ TABLE out_tab INDEX 3.

MOVE w_city TO out_tab-value.

MODIFY out_tab INDEX sy-tabix.

READ TABLE out_tab INDEX 4.

MOVE w_pstlc TO out_tab-value.

MODIFY out_tab INDEX sy-tabix.

READ TABLE out_tab INDEX 5.

MOVE w_landx TO out_tab-value.

MODIFY out_tab INDEX sy-tabix.

ENDFORM. "get_comcode

Just change the the above code as per ur requirement, you should pass LIFNR value and get details from LFA1 table.

Regards

Bala Krishna

Former Member
0 Kudos

Check this example, It may be useful.

/: PERFORM SUM IN PROGRAM ZPROGRAM

/: USING &VAR1&

/: USING &VAR2&

/: CHANGING &RESULT&

/: ENDPERFORM

In the program(ZPROGRAM), we need to write the form ....

FORM SUM TABLES INTAB STRUCTURE ITCSY

OUTTAB STRUCTURE ITCSY.

data: field1 type i,

field2 type i,

result type i.

TO read the values from the ITAB you have to use this logic.

READ TABLE INTAB WITH KEY NAME = 'VAR1'.

IF SY-SUBRC = 0.

FIELD1 = INTAB-VALUE.

ENDIF.

READ TABLE INTAB WITH KEY NAME = 'VAR2'.

IF SY-SUBRC = 0.

FIELD2 = ITAB-VALUE.

ENDIF.

RESULT = V_FIELD1 + V_FIELD2.

READ TABLE OUTTAB INDEX 1.

IF SY-SUBRC = 0.

OTAB-VALUE = RESULT.

MODIFY OUTTAB INDEX 1 .

ENDIF.

ENDFORM.