‎2009 Dec 24 1:48 AM
Please read my code as below. My problem always exit even when call bapi successfully. I debug this code, find RETURN is null.
I'm a newbie at ABAP. please help me.
CALL FUNCTION 'BAPI_PO_GETITEMS'
EXPORTING
...
TABLES
...
RETURN = RETURN.
if RETURN-TYPE u300Au300B 'S'.
OUTPUT-RETCODE = RETURN-TYPE.
exit.
endif.
‎2009 Dec 24 2:57 AM
Hi,
There are two things you should note.
1. RETURN is a table parameter. So you need to loop through it. You seem to be reading only the header of the table.
2. This BAPI returns an EMPTY table RETURN if it is successful in reading the PO items. In this case your code will exit whenever PO items are read successfully.
You change your code like below:
DATA: v_failure TYPE c.
.....
....
CLEAR v_failure.
LOOP AT return.
IF return-type IN ('E', 'A'). "Error or Abend - both un-successful
v_failure = 'X'.
EXIT. "This EXIT is to exit the loop if any error is found
ENDIF.
ENDLOOP.
IF v_failure = 'X'.
EXIT. "This EXIT is to exit your routine.
ENDIF.
Cheers,
Suresh
‎2009 Dec 24 2:29 AM
Hello,
If you provide a valid PO number, then the RETURN parameter will be empty. If you give an invalid PO, you will get RETURN with TYPE NE 'S'.
Thanks,
Venu
‎2009 Dec 24 2:57 AM
Hi,
There are two things you should note.
1. RETURN is a table parameter. So you need to loop through it. You seem to be reading only the header of the table.
2. This BAPI returns an EMPTY table RETURN if it is successful in reading the PO items. In this case your code will exit whenever PO items are read successfully.
You change your code like below:
DATA: v_failure TYPE c.
.....
....
CLEAR v_failure.
LOOP AT return.
IF return-type IN ('E', 'A'). "Error or Abend - both un-successful
v_failure = 'X'.
EXIT. "This EXIT is to exit the loop if any error is found
ENDIF.
ENDLOOP.
IF v_failure = 'X'.
EXIT. "This EXIT is to exit your routine.
ENDIF.
Cheers,
Suresh