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

help with perform

Former Member
0 Likes
653

HI ALL

in this code i use table nametab_3001 but i have a lot of tables 3001 3002 ...

that i have to do the same code.

what have to be change is the just the table

nametab_3001 & wa_nametab_3001

how can i do it in better way instead of copy this code and change it in all tables

i do it in perform maybe some can help me with that?

Regards

SELECT SINGLE perid pernr nachn vorna

FROM pa0002

INTO (taz9,emp_pernr,famliy_name,first_name)

WHERE pernr = wa_et_infty_modif-pernr

AND begda LE wa_et_infty_modif-bdate

AND endda GE wa_et_infty_modif-bdate.

lv_str1 = famliy_name(12). "Employee last name

SHIFT lv_str1 LEFT DELETING LEADING space. "Miror

TRANSLATE lv_str1 USING c_translate. "Chinese

wa_nametab_3001-mishpacha = lv_str1.

wa_nametab_3001-emp_pernr = emp_pernr.

APPEND wa_nametab_3001 TO nametab_3001.

CLEAR wa_nametab_3001.

lv_str2 = first_name(7). "Employee first name

SHIFT lv_str2 LEFT DELETING LEADING space. "Miror

TRANSLATE lv_str2 USING c_translate. "Chinese

wa_nametab_3001-praty = lv_str2.

LOOP AT nametab_3001 INTO wa_nametab_3001.

IF wa_nametab_3001-emp_pernr = wa_et_infty_modif-pernr.

MOVE: lv_str2 TO wa_nametab_3001-praty.

MODIFY nametab_3001 FROM wa_nametab_3001 TRANSPORTING praty.

CLEAR wa_nametab_3001.

ENDIF.

ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
626

Hi

U can use the field-symbols

Max

7 REPLIES 7
Read only

Former Member
0 Likes
626

hi

if i can't do that please tell me

Regards

Read only

Former Member
0 Likes
627

Hi

U can use the field-symbols

Max

Read only

0 Likes
626

hi max

u can give me example how i can use here field symbol

i new with this topic

regards

Read only

0 Likes
626

Hi

try this sample

TYPES: BEGIN OF TY_LINE,
        MISHPACHA,
        EMP_PERNR,
        PRATY,
       END  OF TY_LINE.

DATA: ITAB1 TYPE STANDARD TABLE OF TY_LINE,
      ITAB2 TYPE STANDARD TABLE OF TY_LINE,
      ITAB3 TYPE STANDARD TABLE OF TY_LINE,
      ITAB4 TYPE STANDARD TABLE OF TY_LINE,
      ITAB5 TYPE STANDARD TABLE OF TY_LINE.


PERFORM FILL_TAB USING: 'ITAB1[]' 'A' 'B',
                        'ITAB2[]' 'C' 'D',
                        'ITAB3[]' 'E' 'F',
                        'ITAB4[]' 'G' 'H',
                        'ITAB5[]' 'I' 'L'.

PERFORM UPDATE_TAB USING: 'ITAB1[]' 'A' 'E',
                          'ITAB2[]' 'D' 'B',
                          'ITAB3[]' 'E' 'B',
                          'ITAB4[]' 'H' 'B',
                          'ITAB5[]' 'I' 'B'.

*&---------------------------------------------------------------------*
*&      Form  FILL_TAB
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0041   text
*      -->P_LV_STR1  text
*      -->P_EMP_PERNR  text
*----------------------------------------------------------------------*
FORM FILL_TAB USING    TABNAME
                       P_LV_STR1
                       P_EMP_PERNR.

  FIELD-SYMBOLS: <TAB>   TYPE TABLE.

  DATA: WA TYPE TY_LINE.

  ASSIGN (TABNAME) TO <TAB>.

  WA-MISHPACHA = P_LV_STR1.

  WA-EMP_PERNR = P_EMP_PERNR.

  APPEND WA TO <TAB>.

ENDFORM.                    " FILL_TAB
*&---------------------------------------------------------------------*
*&      Form  UPDATE_TAB
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_TAB  text
*      -->P_VALUE  text
*----------------------------------------------------------------------*
FORM UPDATE_TAB USING    P_TAB
                         P_CHECK
                         P_VALUE.
  FIELD-SYMBOLS: <TAB>   TYPE TABLE,
                 <WA>    TYPE ANY,
                 <FIELD> TYPE ANY.

  ASSIGN (P_TAB) TO <TAB>.

  LOOP AT <TAB> ASSIGNING <WA>.

    ASSIGN COMPONENT 'EMP_PERNR' OF STRUCTURE <WA> TO <FIELD>.
    CHECK <FIELD> = P_CHECK.

    ASSIGN COMPONENT 'PRATY' OF STRUCTURE <WA> TO <FIELD>.
    <FIELD> = P_VALUE.
  ENDLOOP.
ENDFORM.                    " UPDATE_TAB

Max

Read only

ibrahim_u
Active Participant
0 Likes
626


perform do_something tables nametab_3001
                                 using wa_nametab_3001.

perform do_something tables nametab_3002
                                 using wa_nametab_3002.

perform do_something tables nametab_3003
                                 using wa_nametab_3003.



form do_something tables p_tab structure nametab
                             using p_wa  structure nametab. 

SELECT SINGLE perid pernr nachn vorna
FROM pa0002
INTO (taz9,emp_pernr,famliy_name,first_name)
WHERE pernr = wa_et_infty_modif-pernr
AND begda LE wa_et_infty_modif-bdate
AND endda GE wa_et_infty_modif-bdate.


lv_str1 = famliy_name(12). "Employee last name
SHIFT lv_str1 LEFT DELETING LEADING space. "Miror
TRANSLATE lv_str1 USING c_translate. "Chinese
p_wa-mishpacha = lv_str1.
p_wa-emp_pernr = emp_pernr.
APPEND p_wa- TO p_tab.
CLEAR p_wa.

lv_str2 = first_name(7). "Employee first name
SHIFT lv_str2 LEFT DELETING LEADING space. "Miror
TRANSLATE lv_str2 USING c_translate. "Chinese
p_wa-praty = lv_str2.


LOOP AT p_tab INTO p_wa.

IF p_wa-emp_pernr = wa_et_infty_modif-pernr.

MOVE: lv_str2 TO p_wa-praty.
MODIFY p_tab FROM p_wa TRANSPORTING praty.
CLEAR p_wa.
ENDIF.
ENDLOOP. 

endform.
Read only

Former Member
0 Likes
626

Thankes ibrahim

i try it

Best regards

Read only

kostas_tsioubris
Contributor
0 Likes
626

Hi,

does all your tables have the same structure? If so just put this code in a routine.

e.g.

data : nametab_3001 like sflight occurs 0 with header line,
                  nametab_3002 like sflight occurs 0 with header line.

....

perform routine tables nametab_3001.

perform routine tables nametab_3002.

*routine definition.
form routine tables pt_nametab structure sflight.
data: w_nametab like sflight.

*your code here

endform.

Kostas