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

in loop where condition is not working

Former Member
0 Likes
3,230

Dear all

i have an query that in loop where condition is not working , plz find below code.

DATA : IT_GETSTATEMENT TYPE STANDARD TABLE OF BAPI3008_2 WITH HEADER LINE.

CALL FUNCTION 'BAPI_AP_ACC_GETSTATEMENT'
EXPORTING
companycode = T_BUKRS
vendor = T_LIFNR
date_from = t_date-low
date_to = t_date-high
* NOTEDITEMS = ' '
* IMPORTING
* RETURN =
TABLES

lineitems = IT_GETSTATEMENT.

LOOP AT IT_GETSTATEMENT where doc_type = 'AB'.

endloop.

My question is in above loop where condition doc_type = 'AB'. is not working.

Dear all

i have an query that in loop where condition is not working , plz find below code.

DATA : IT_GETSTATEMENT TYPE STANDARD TABLE OF BAPI3008_2 WITH HEADER LINE.

CALL FUNCTION 'BAPI_AP_ACC_GETSTATEMENT'
EXPORTING
companycode = T_BUKRS
vendor = T_LIFNR
date_from = t_date-low
date_to = t_date-high
* NOTEDITEMS = ' '
* IMPORTING
* RETURN =
TABLES

lineitems = IT_GETSTATEMENT.

LOOP AT IT_GETSTATEMENT where doc_type = 'AB'.

endloop.

My question is in above loop where condition doc_type = 'AB'. is not working.

10 REPLIES 10
Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,649

Your first loop should be AT RETURN table for error message(s)...

And please remove this ugly HEADER LINE.

Read only

0 Likes
2,649

i tried by removing header line , declare as

DATA : IT_GETSTATEMENT TYPE STANDARD TABLE OF BAPI3008_2,

WA_GETSTATEMENT TYPE STANDARD TABLE OF BAPI3008_2

LOOP AT IT_GETSTATEMENT INTO WA_GETSTATEMENT where doc_type = 'AB'.

endloop.

STILL MY PROBLEM IS NOT RESOLVED ,WHERE CONDITION IS NOT WORKING


Read only

0 Likes
2,649

Are there error(s) in RETURN table or any item returned in LINEITEMS, can you see items with FBL1N?

Read only

0 Likes
2,649
DATA : IT_GETSTATEMENT TYPE STANDARD TABLE OF BAPI3008_2,
WA_GETSTATEMENT TYPE STANDARD TABLE OF BAPI3008_2
LOOP AT IT_GETSTATEMENT INTO WA_GETSTATEMENT

Well, the above is syntactically incorrect. You can't loop at a table into another internal table. So at least at this point the WHERE clause is irrelevant.

Please be precise. What do you mean by "not working". (shouting in BOLD CAPITALS doesn't in fact provide addiitional useful information to folk who are trying to help you). How have you demonstrated that it isn't working? Do you know there are documents with doc_type AB? Have you used debug? Have you examined the flow in debugger?

Read only

0 Likes
2,649

Dear sir

I am not shouting , i am just trying to highlight the area so that you understand quickly, sorry if you feel bad .i used debug also but after entering in loop documents related to doc_type AB is coming with other documents also.

Read only

0 Likes
2,649

Dear sir

I am not shouting , i am just trying to highlight the area so that you understand quickly, sorry if you feel bad .i used debug also but after entering in loop documents related to doc_type AB is coming with other documents also.

Read only

0 Likes
2,649

Try a code like following sample

DATA : lineitems TYPE STANDARD TABLE OF bapi3008_2,
       return TYPE bapireturn.
FIELD-SYMBOLS: <lineitem> TYPE bapi3008_2.
PARAMETERS: p_comp TYPE bapi3008_1-comp_code,
            p_vendor TYPE bapi3008_1-vendor.
SELECT-OPTIONS so_date FOR <lineitem>-pstng_date NO-EXTENSION.

START-OF-SELECTION.
  " call BAPI
  CALL FUNCTION 'BAPI_AP_ACC_GETSTATEMENT'
    EXPORTING
      companycode = p_comp
      vendor      = p_vendor
      date_from   = so_date-low
      date_to     = so_date-high
    IMPORTING
      return      = return
    TABLES
      lineitems   = lineitems.
  " Check for errors
  IF return-type IS NOT INITIAL.
    MESSAGE return-message TYPE return-type.
  ENDIF.
  " Loop at returned items
  LOOP AT lineitems ASSIGNING <lineitem> WHERE doc_type = 'AB'.
    BREAK-POINT. " for testing purpose
  ENDLOOP.
Read only

0 Likes
2,649

".i used debug also but after entering in loop documents related to doc_type AB is coming with other documents also."

Show me a screen shot of the debug screen, inside the loop, with the field wagetstatement-doctype with a value that's not AB.

Read only

0 Likes
2,649

Thanks Raymond sir..

Read only

0 Likes
2,649

ok. sir i will remember those things which you sugggested from next time ,,Thanks sir