Skip to Content
-1

in loop where condition is not working

May 17, 2017 at 07:07 AM

88

avatar image

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 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Raymond Giuseppi
May 17, 2017 at 07:35 AM
0

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

And please remove this ugly HEADER LINE.

Show 8 Share
10 |10000 characters needed characters left characters exceeded

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


0

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

0
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?

0

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.

0

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.

0

".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.

0

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.
0

Thanks Raymond sir..

0