‎2008 May 05 12:42 PM
Hi everyone, here is my code, I need help where there are question marks :
START-OF-SELECTION.
SELECT * INTO CORRESPONDING FIELDS OF TABLE t_table2
FROM ztmm_fourho.
IF ??????
SELECT belnr hkont shkzg mwskz wrbtr FROM bseg
INTO CORRESPONDING FIELDS OF TABLE t_table1
FOR ALL ENTRIES IN t_table2
WHERE hkont = t_table2-zaccnt AND
gjahr = p_year AND
bukrs = p_comp.
ELSE. ????
ENDIF.
My problem is the following : t_table2 is a table with 2 columns both containing a char type. I would like to perform the "SELECT" only if for at least one line contained in t_table2 both columns ARE filled, meaning that I would like to display an error message (in the "else" condition) if for some lines, only the first column contains some information. In the code above, ztmm_fourho is a custom database table previously filled in through transaction code SM30;
any help would be much appreciated and rewarded,
CK
‎2008 May 05 12:51 PM
START-OF-SELECTION.
SELECT * INTO CORRESPONDING FIELDS OF TABLE t_table2
FROM ztmm_fourho.
IF sy-subrc = 0.
loop at t_table2.
if t_table2-field2 is initial.
v_flag = 'X'.
exit.
endif.
endloop.
endif.
IF v_flag is initial.
SELECT belnr hkont shkzg mwskz wrbtr FROM bseg
INTO CORRESPONDING FIELDS OF TABLE t_table1
FOR ALL ENTRIES IN t_table2
WHERE hkont = t_table2-zaccnt AND
gjahr = p_year AND
bukrs = p_comp.
ELSE.
*error message ..
ENDIF.
‎2008 May 05 12:47 PM
‎2008 May 05 12:51 PM
START-OF-SELECTION.
SELECT * INTO CORRESPONDING FIELDS OF TABLE t_table2
FROM ztmm_fourho.
IF sy-subrc = 0.
loop at t_table2.
if t_table2-field2 is initial.
v_flag = 'X'.
exit.
endif.
endloop.
endif.
IF v_flag is initial.
SELECT belnr hkont shkzg mwskz wrbtr FROM bseg
INTO CORRESPONDING FIELDS OF TABLE t_table1
FOR ALL ENTRIES IN t_table2
WHERE hkont = t_table2-zaccnt AND
gjahr = p_year AND
bukrs = p_comp.
ELSE.
*error message ..
ENDIF.