Application Development 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: 

Deleting Data Package with Abap - error in Abap statement

bhat_vaidya2
Active Participant
0 Kudos
686

Hi,

I am trying to delete data with abap but my logic is not working and it failed with error message Error in an abap/4 statement when processing

requirement

- Delete data package when plant = INDIA

- Delete data package when Area = 01 OR Group = J001 in customer master data table.

Logic

Data: T_Data TYPE DATA_PACKAGE_STRUCTURE Occurs 0 WITH HEADER LINE.
data: lt_BI0_PCUSTOMER LIKE /BI0/PCUSTOMER OCCURS 0 WITH HEADER LINE.
LOOP AT DATA_PACKAGE.
MOVE-CORRESPONDING DATA_PACKAGE TO T_DATA.
Refresh lt_BI0_PCUSTOMER.

select * from /BI0/PCUSTOMER into TABLE lt_BI0_PCUSTOMER
WHERE CUSTOMER = T_DATA-SOLD_TO.
Read table lt_BI0_PCUSTOMER WITH KEY CUSTOMER = T_DATA-SOLD_TO.
IF sy-subrc EQ 0.
LOOP AT lt_BI0_PCUSTOMER.
 
IF lt_BI0_PCUSTOMER-AREA= '01' or
lt_BI0_PCUSTOMER-GROUP = 'J001'.
DELETE T_DATA.
APPEND T_DATA.
endif.
ENDLOOP.
ENDIF.
ENDLOOP.
DATA_PACKAGE[] = T_DATA[].
* Delete data package when Plant EQ INDIA
DELETE DATA_PACKAGE WHERE PLANT = 'INDIA'.

thanks

Edited by: Bhat Vaidya on Oct 19, 2010 8:41 AM

Edited by: Thomas Zloch on Oct 19, 2010 9:55 AM

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos
183

I suppose this is the start-routine of a BW transfer rule, try the following code

DATA: ls_datapak_line TYPE transfer_structure,
      lv_area  LIKE /bi0/pcustomer-area,
      lv_group LIKE /bi0/pcustomer-group.
* Delete data package when Plant EQ INDIA
DELETE datapak WHERE plant = 'INDI'. " ?
* Then only for non INDIA record (performance)
LOOP AT datapak INTO ls_datapak_line.
  SELECT SINGLE area GROUP
    INTO (lv_area, lv_group)
    FROM /bi0/pcustomer
    WHERE customer = ls_datapak_line-sold_to
      AND objvers = 'A'.
  CHECK sy-subrc EQ 0.
  IF lv_area= '01' or LV_GROUP = 'J001'.
    DELETE datapak.
  ENDIF.
ENDLOOP.

But is not PLANT (WERKS) only FOUR character long, do you need to read /BI0/PPLANT to find COUNTRY Country key "IN" ?

Regards,

Raymond

4 REPLIES 4

ravi_lanjewar
Contributor
0 Kudos
183

Hi,


DELETE DATA_PACKAGE WHERE PLANT = 'INDIA'.

Above syntax for delete data from internal table

For deleting the database table write statement as follows


DELETE From DATA_PACKAGE WHERE PLANT = 'INDIA'

Your are missing the from keyword from statement.

What could i have understand, if it is your solution of Query.

Exactly you want to delete data from database table or internal table ?

Former Member
0 Kudos
183

Try delete statement on internal table T_DATA and pass the result to DATA_PACKAGE.

DATA_PACKAGE[] = T_DATA[].
* Delete data package when Plant EQ INDIA
DELETE DATA_PACKAGE WHERE PLANT = 'INDIA'.

to

* Delete data package when Plant EQ INDIA
DELETE T_DATA WHERE PLANT = 'INDIA'.
DATA_PACKAGE[] = T_DATA[].

KR

VR

raymond_giuseppi
Active Contributor
0 Kudos
184

I suppose this is the start-routine of a BW transfer rule, try the following code

DATA: ls_datapak_line TYPE transfer_structure,
      lv_area  LIKE /bi0/pcustomer-area,
      lv_group LIKE /bi0/pcustomer-group.
* Delete data package when Plant EQ INDIA
DELETE datapak WHERE plant = 'INDI'. " ?
* Then only for non INDIA record (performance)
LOOP AT datapak INTO ls_datapak_line.
  SELECT SINGLE area GROUP
    INTO (lv_area, lv_group)
    FROM /bi0/pcustomer
    WHERE customer = ls_datapak_line-sold_to
      AND objvers = 'A'.
  CHECK sy-subrc EQ 0.
  IF lv_area= '01' or LV_GROUP = 'J001'.
    DELETE datapak.
  ENDIF.
ENDLOOP.

But is not PLANT (WERKS) only FOUR character long, do you need to read /BI0/PPLANT to find COUNTRY Country key "IN" ?

Regards,

Raymond

0 Kudos
183

Hi Giuseppi ,

Big thanks to you. My issue is now resolved with your logic.

thanks