‎2009 Oct 08 9:30 AM
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
‎2009 Oct 08 9:33 AM
Hi,
Use 'is initial' clause to find the initial value.
Thanks,
Krishna
‎2009 Oct 08 9:33 AM
Hi,
Use 'is initial' clause to find the initial value.
Thanks,
Krishna
‎2009 Oct 08 9:45 AM
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
‎2009 Oct 08 9:49 AM
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
‎2009 Oct 08 9:56 AM
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
‎2009 Oct 08 2:29 PM
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).