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

select statement check the empty fields in table

Former Member
0 Likes
4,641

Dear ABAP experts,

I am developing a function module where in that function i am getting a table as input and i want to do 2 things:

1 check the total empty columns and excluded from the select statement.

2 the select statement should get only the rows that has all its field appeared at least once in the input table.

although i am new to abap i did some searching and i reached to that code but the data is not accurate


Select * from VBRP into table zBAPI_output_VBRP
  FOR ALL ENTRIES IN zBAPI_INPUT_VBRP
  where VBELN = zBAPI_INPUT_VBRP-VBELN
  and ERDAT between zBAPI_FROM_DATE and ZBAPI_TO_DATE
  and MATKL = zBAPI_INPUT_VBRP-MATKL
  and PRCTR = zBAPI_INPUT_VBRP-PRCTR
  and VKORG_AUFT = zBAPI_INPUT_VBRP-VKORG_AUFT.

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,929

Hi,

Use 'is initial' clause to find the initial value.

Thanks,

Krishna

5 REPLIES 5
Read only

Former Member
0 Likes
1,930

Hi,

Use 'is initial' clause to find the initial value.

Thanks,

Krishna

Read only

Former Member
0 Likes
1,929

thanks for your reply

but i don't want to go field by field and write if condition could you give me how to write the select statement according to my initial question

Read only

Former Member
0 Likes
1,929

Hi,

Before this select Query you can check Not Initial Condition for the required fields,

if zBAPI_INPUT_VBRP- field1 and zBAPI_INPUT_VBRP-field2... Not Initial.

Select * from VBRP into table zBAPI_output_VBRP

FOR ALL ENTRIES IN zBAPI_INPUT_VBRP

where VBELN = zBAPI_INPUT_VBRP-VBELN

and ERDAT between zBAPI_FROM_DATE and ZBAPI_TO_DATE

and MATKL = zBAPI_INPUT_VBRP-MATKL

and PRCTR = zBAPI_INPUT_VBRP-PRCTR

and VKORG_AUFT = zBAPI_INPUT_VBRP-VKORG_AUFT.

Endif.

Hope it helps,

Regards,

Mansi

Read only

Former Member
0 Likes
1,929

thanks for the reply

but in that case i have to write on SQL statement whenever i find a field is initial to exclude it from the select

Read only

Former Member
0 Likes
1,929

i solved it as follow and now all my points achieved


DATA: COND(72) TYPE C,
      ITAB LIKE TABLE OF COND.
Data wa1 type VBRP.

if ( zBAPI_FROM_DATE is not initial and ZBAPI_TO_DATE is not INITIAL ).
CONCATENATE 'ERDAT between zBAPI_FROM_DATE and ZBAPI_TO_DATE' ' ' INTO COND.
APPEND COND TO ITAB.
endif.
LOOP AT zBAPI_INPUT_VBRP INTO wa1.
if (   wa1-MATKL  is not initial ).
CONCATENATE ' and MATKL = zBAPI_INPUT_VBRP-MATKL' ' ' INTO COND.
APPEND COND TO ITAB.
exit.
endif.
endloop.
LOOP AT zBAPI_INPUT_VBRP INTO wa1.
if ( wa1-PRCTR is not initial ).
CONCATENATE 'and PRCTR = zBAPI_INPUT_VBRP-PRCTR' '' INTO COND.
APPEND COND TO ITAB.
exit.
endif.
endloop.
LOOP AT zBAPI_INPUT_VBRP INTO wa1.
if ( wa1-VKORG_AUFT is not initial ).
CONCATENATE ' and VKORG_AUFT = zBAPI_INPUT_VBRP-VKORG_AUFT' ' ' INTO COND.
APPEND COND TO ITAB.
exit.
endif.
ENDLOOP.
Select * from VBRP into table zBAPI_output_VBRP
  FOR ALL ENTRIES IN zBAPI_INPUT_VBRP
  where (ITAB).