He aquí un ejemplo sencillo que puede tener diversas aplicaciones.
REPORT ztest_field_symbol.
PARAMETERS:
p_bukrs TYPE bseg-bukrs,
p_gjahr TYPE bseg-gjahr,
p_belnr TYPE bseg-belnr.
DATA:
t_bsak TYPE STANDARD TABLE OF bsak,
t_bsik TYPE STANDARD TABLE OF bsik,
BEGIN OF t_data OCCURS 0,
belnr TYPE belnr_d,
augbl TYPE augbl,
END OF t_data,
s_data LIKE LINE OF t_data.
FIELD-SYMBOLS:
<bs*k_tab> TYPE ANY TABLE,
<bs*k> TYPE any,
<any> TYPE any.
REFRESH: t_bsak[], t_bsik[].
SELECT * FROM bsak INTO TABLE t_bsak
WHERE augbl EQ p_belnr
AND bukrs EQ p_bukrs
AND belnr NE p_belnr.
IF sy-subrc NE 0.
SELECT * FROM bsik INTO TABLE t_bsik
WHERE bukrs EQ p_bukrs
AND belnr EQ p_belnr
AND gjahr EQ p_gjahr.
IF sy-subrc EQ 0.
ENDIF.
ENDIF.
BREAK-POINT.
IF t_bsak[] IS NOT INITIAL.
ASSIGN TABLE FIELD t_bsak TO <bs*k_tab>.
ELSE.
ASSIGN TABLE FIELD t_bsik TO <bs*k_tab>.
ENDIF.
REFRESH: t_data[]. CLEAR: s_data.
UNASSIGN <bs*k>.
LOOP AT <bs*k_tab> ASSIGNING <bs*k>.
UNASSIGN: <any>.
ASSIGN COMPONENT 'BELNR' OF STRUCTURE <bs*k> TO <any>.
IF sy-subrc EQ 0.
MOVE <any> TO s_data-belnr.
ENDIF.
UNASSIGN: <any>.
ASSIGN COMPONENT 'AUGBL' OF STRUCTURE <bs*k> TO <any>.
IF sy-subrc EQ 0.
MOVE <any> TO s_data-augbl.
ENDIF.
APPEND s_data TO t_data.
CLEAR: s_data.
ENDLOOP.
BREAK-POINT.
No hay comentarios:
Publicar un comentario