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

BDC Delete

SG141
Active Participant
0 Likes
1,352

I am working on a requirement where I have to delete the data using BDC for transaction XD02. BDC recording is available.

How can I program the using the BDC available.

Please explain with a sample program.

Thank you.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,260

You can use BAPI to delete Customer master

Use FM - BAPI_CUSTOMER_DELETE

Thanks

Seshu

9 REPLIES 9
Read only

Former Member
0 Likes
1,261

You can use BAPI to delete Customer master

Use FM - BAPI_CUSTOMER_DELETE

Thanks

Seshu

Read only

SG141
Active Participant
0 Likes
1,260

Seshu,

Thanx for your reply, However I am asked to use BDC for this.

Read only

0 Likes
1,260

BAPI_CUSTOMER_DELETE is the BAPI that can delete Customers.

BAPI is always suggested rather than going for a BDC. other words you can suggest the one that BAPI is better rather writing a BDC and is more perfect than BDC.

Regards

Gopi

If you are more particular to go with BDC then you can go ahead, if not i suggest to for a BAPI only

Message was edited by:

Gopi Narendra

Read only

SG141
Active Participant
0 Likes
1,260

Ok let me modify my question.

I would like to use one of the BDC recordings available to delete the data if meet does not a certain criteria.

How can i achieve it???

Read only

0 Likes
1,260

Hi Kathik,

I would suggest BAPI always than BDC ,

I deleted two customers in my system by using BDC ( I did recording )

See the code below

report ZTEST_DELETE1

no standard page heading line-size 255.

include bdcrecx1.

start-of-selection.

perform open_group.

perform bdc_dynpro using 'SAPMF02D' '0101'.

perform bdc_field using 'BDC_CURSOR'

'RF02D-D0110'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02D-KUNNR'

'1010019'.

perform bdc_field using 'RF02D-D0110'

'X'.

perform bdc_dynpro using 'SAPMF02D' '0110'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-NAME1'.

perform bdc_field using 'BDC_OKCODE'

'=0520'.

perform bdc_field using 'KNA1-NAME1'

'p p'.

perform bdc_field using 'KNA1-SORTL'

'P'.

perform bdc_field using 'KNA1-STRAS'

'112 FULTON ST s'.

perform bdc_field using 'KNA1-ORT01'

'NEW YORK'.

perform bdc_field using 'KNA1-PSTLZ'

'10038'.

perform bdc_field using 'KNA1-LAND1'

'US'.

perform bdc_field using 'KNA1-REGIO'

'NY'.

perform bdc_field using 'KNA1-SPRAS'

'EN'.

perform bdc_dynpro using 'SAPMF02D' '0520'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-LOEVM'.

perform bdc_field using 'BDC_OKCODE'

'=UPDA'.

perform bdc_field using 'KNA1-LOEVM'

'X'.

perform bdc_transaction using 'XD02'.

perform close_group.

You can modify the above code as per ur requirement.

Thanks

Seshu

Read only

SG141
Active Participant
0 Likes
1,260

report ZTEST_DELETE1
no standard page heading line-size 255.

include bdcrecx1.

start-of-selection.

perform open_group.

perform bdc_dynpro using 'SAPMF02D' '0101'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-D0110'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02D-KUNNR'
'1010019'.
perform bdc_field using 'RF02D-D0110'
'X'.
perform bdc_dynpro using 'SAPMF02D' '0110'.
perform bdc_field using 'BDC_CURSOR'
'KNA1-NAME1'.
perform bdc_field using 'BDC_OKCODE'
'=0520'.
perform bdc_field using 'KNA1-NAME1'
'p p'.
perform bdc_field using 'KNA1-SORTL'
'P'.
perform bdc_field using 'KNA1-STRAS'
'112 FULTON ST s'.
perform bdc_field using 'KNA1-ORT01'
'NEW YORK'.
perform bdc_field using 'KNA1-PSTLZ'
'10038'.
perform bdc_field using 'KNA1-LAND1'
'US'.
perform bdc_field using 'KNA1-REGIO'
'NY'.
perform bdc_field using 'KNA1-SPRAS'
'EN'.
perform bdc_dynpro using 'SAPMF02D' '0520'.
perform bdc_field using 'BDC_CURSOR'
'KNA1-LOEVM'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_field using 'KNA1-LOEVM'
'X'.
perform bdc_transaction using 'XD02'.

perform close_group.

Thanks Seshu ...awarded points for your answer.

However I would be passing the values of the fields through Internal Table.

Also you please explain your code in detail.

Read only

0 Likes
1,260

Hi Karthik,

First you need to get the data from file to internal table

Depends file path : If it is Presentation server then you can use GUI_UPLOAD

if it is application server then you can use OPEN DATASET Command.

Keep the file data into internal table.

loop at I_data.

between you need to use the code ..

perform bdc_dynpro using 'SAPMF02D' '0101'.

perform bdc_field using 'BDC_CURSOR'

'RF02D-D0110'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02D-KUNNR'

<b>'1010019'.</b> -> here I am passing value manually ,you need to use internal table value ( Customer Number )..

perform bdc_field using 'RF02D-D0110'

'X'.

perform bdc_dynpro using 'SAPMF02D' '0110'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-NAME1'.

perform bdc_field using 'BDC_OKCODE'

'=0520'.

perform bdc_field using 'KNA1-NAME1'

'p p'.

perform bdc_field using 'KNA1-SORTL'

'P'.

perform bdc_field using 'KNA1-STRAS'

'112 FULTON ST s'.

perform bdc_field using 'KNA1-ORT01'

'NEW YORK'.

perform bdc_field using 'KNA1-PSTLZ'

'10038'.

perform bdc_field using 'KNA1-LAND1'

'US'.

perform bdc_field using 'KNA1-REGIO'

'NY'.

perform bdc_field using 'KNA1-SPRAS'

'EN'.

perform bdc_dynpro using 'SAPMF02D' '0520'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-LOEVM'.

perform bdc_field using 'BDC_OKCODE'

'=UPDA'.

perform bdc_field using 'KNA1-LOEVM'

'X'.

perform bdc_transaction using 'XD02'.

perform close_group.

endloop.

I hope you got it

Thanks

Seshu

Read only

SG141
Active Participant
0 Likes
1,260

I understood. I am writing a select query and filling the internal table. For certain entries in the internal table I have to perform this <b>BDC</b>

Read only

0 Likes
1,260

A bit late, but I was also looking for a solution to delete customers... Just sharing my solution too.

There is no BAPI to do this, the only BAPI's available are just CALL TRANSACTIONS... Not real BAPI's at all...

So that's what we need to do to. Unfortunately.

Instead of using XD02, I choose XD06.

REPORT zbc_temp.

INCLUDE bdcrecxy.

DATA: tp_kunnr TYPE kunnr VALUE '0900068280'.
DATA: tp_loevm TYPE loevm.

REFRESH: bdcdata.
CLEAR:   bdcdata.


* Check if changes are required:
SELECT SINGLE loevm FROM  kna1
                    INTO  tp_loevm
                    WHERE kunnr = tp_kunnr.

IF sy-subrc = 0 AND
   tp_loevm IS INITIAL.

* Build the internal table:
  PERFORM: bdc_dynpro USING 'SAPMF02D' '0500',
           bdc_field  USING 'RF02D-KUNNR' tp_kunnr,
           bdc_field  USING 'RF02D-BUKRS' '',
           bdc_field  USING 'RF02D-VKORG' '',
           bdc_field  USING 'RF02D-VTWEG' '',
           bdc_field  USING 'RF02D-SPART' '',
           bdc_field  USING 'BDC_OKCODE' '/00'.

  PERFORM: bdc_dynpro USING 'SAPMF02D' '0520',
           bdc_field  USING 'KNA1-LOEVM' 'X',
           bdc_field  USING 'BDC_OKCODE' '=UPDA'.
ENDIF.

* The display mode mode can take the following values:
*   'A' Display the screens
*   'E' Only display if an error occurs
*   'N' Do not display
CALL TRANSACTION 'XD06' USING bdcdata MODE 'N'.

Please note that I have not applied LOCKING in the example. Would be the proper way to do it though.