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

How to psss a table from sapscript to routine program

Former Member
0 Likes
721

HI,

i want to pass a table from sapscript to routine program.

the requirment is to sor the table by material number wise.

how do we pass throug itcsy structure.

Regards,

Balachandran

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
665

REPORT YMMR_TDS_LPRG .

TABLES: ADRC."Central address administration

----


  • FORM FETCH_VEN_ADD *

----


  • ........ *

----


  • --> IN_TAB *

  • --> OUT_TAB *

----


FORM FETCH_VEN_ADD TABLES IN_TAB STRUCTURE ITCSY

OUT_TAB STRUCTURE ITCSY.

DATA: L_STREET4 LIKE ADRC-CITY2,

L_STREET5 LIKE ADRC-LOCATION,

L_INDEX1 LIKE SY-TABIX.

DATA: LEN TYPE I.

DATA: Z1(5) VALUE '00000'.

LEN = STRLEN( IN_TAB-VALUE ).

IF LEN = 5.

CONCATENATE '00000' IN_TAB-VALUE INTO IN_TAB-VALUE.

ELSEIF LEN = 6.

CONCATENATE '0000' IN_TAB-VALUE INTO IN_TAB-VALUE.

ENDIF.

SELECT CITY2 LOCATION FROM ADRC

INTO (L_STREET4,L_STREET5)

WHERE ADDRNUMBER = IN_TAB-VALUE.

IF SY-SUBRC = 0.

LOOP AT OUT_TAB.

CLEAR L_INDEX1.

IF OUT_TAB-NAME = 'ADRC-CITY2'.

L_INDEX1 = SY-TABIX.

OUT_TAB-VALUE = L_STREET4.

MODIFY OUT_TAB INDEX L_INDEX1 TRANSPORTING VALUE.

ELSE.

L_INDEX1 = SY-TABIX.

OUT_TAB-VALUE = L_STREET5.

MODIFY OUT_TAB INDEX L_INDEX1 TRANSPORTING VALUE.

ENDIF.

ENDLOOP.

ENDIF.

ENDSELECT.

ENDFORM.

Se71

/:PERFORM FETCH_VEN_ADD IN PROGRAM YMMR_TDS_LPRG

/:USING &T001-ADRNR&

/:CHANGING &ADRC-CITY2&

/:CHANGING &ADRC-LOCATION&

/:ENDPERFORM

HI,

i want to pass a table from sapscript to routine program.

the requirment is to sor the table by material number wise.

how do we pass throug itcsy structure.

Regards,

Balachandran

4 REPLIES 4
Read only

Former Member
0 Likes
666

REPORT YMMR_TDS_LPRG .

TABLES: ADRC."Central address administration

----


  • FORM FETCH_VEN_ADD *

----


  • ........ *

----


  • --> IN_TAB *

  • --> OUT_TAB *

----


FORM FETCH_VEN_ADD TABLES IN_TAB STRUCTURE ITCSY

OUT_TAB STRUCTURE ITCSY.

DATA: L_STREET4 LIKE ADRC-CITY2,

L_STREET5 LIKE ADRC-LOCATION,

L_INDEX1 LIKE SY-TABIX.

DATA: LEN TYPE I.

DATA: Z1(5) VALUE '00000'.

LEN = STRLEN( IN_TAB-VALUE ).

IF LEN = 5.

CONCATENATE '00000' IN_TAB-VALUE INTO IN_TAB-VALUE.

ELSEIF LEN = 6.

CONCATENATE '0000' IN_TAB-VALUE INTO IN_TAB-VALUE.

ENDIF.

SELECT CITY2 LOCATION FROM ADRC

INTO (L_STREET4,L_STREET5)

WHERE ADDRNUMBER = IN_TAB-VALUE.

IF SY-SUBRC = 0.

LOOP AT OUT_TAB.

CLEAR L_INDEX1.

IF OUT_TAB-NAME = 'ADRC-CITY2'.

L_INDEX1 = SY-TABIX.

OUT_TAB-VALUE = L_STREET4.

MODIFY OUT_TAB INDEX L_INDEX1 TRANSPORTING VALUE.

ELSE.

L_INDEX1 = SY-TABIX.

OUT_TAB-VALUE = L_STREET5.

MODIFY OUT_TAB INDEX L_INDEX1 TRANSPORTING VALUE.

ENDIF.

ENDLOOP.

ENDIF.

ENDSELECT.

ENDFORM.

Se71

/:PERFORM FETCH_VEN_ADD IN PROGRAM YMMR_TDS_LPRG

/:USING &T001-ADRNR&

/:CHANGING &ADRC-CITY2&

/:CHANGING &ADRC-LOCATION&

/:ENDPERFORM

Read only

che_eky
Active Contributor
0 Likes
665

You cannot pass a table from sapscript to a routine program.

Read only

Former Member
0 Likes
665

Hi Bala,

Please see the code below.

This is the Sub-Routine call in SAP Script.


PERFORM ZGET_TOTAL_AMOUNT IN PROGRAM ZFARFINVADDR
USING &BSEG-FWBAS&
USING &BSET-FWSTE&
USING &BKPF-WAERS&
USING &TOTFLAG&
USING &BSET-SHKZG&
CHANGING &TOT-TOT&
ENDPERFORM

This is the Sub-Routine in the program


FORM zget_total_amount TABLES t_in STRUCTURE itcsy
                                                    t_out STRUCTURE itcsy.
ENDFORM.

As you see in the above example, you need to pass value by value to the structure ITCSY.

The structurre needs Name and Value as the parameters.

While reading the tables in the sub-routine, you need to follow the below given procedure.


READ TABLE t_in WITH KEY name = 'BSEG-FWBAS'.
CHECK sy-subrc = 0.
ws_fwbas = t_in-value.

Read the table using the name and in the record that you retreive, in the field VALUE, you will have the real value.

Hope this is helpful.

Best Regards,

Ram.

Read only

Former Member
0 Likes
665

Answerd