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 to display error message

Former Member
0 Likes
338

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
321

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.

2 REPLIES 2
Read only

Former Member
0 Likes
321

Hi,

if sy-dbcnt <> 0.

Then...

endif.

Reagrds,

Shiva.

Read only

Former Member
0 Likes
322

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.