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: 

Delete KNVD entries with Change History

Former Member
0 Kudos

Hello Experts,

I need to delete KNVD entries based on some Output Type and need to maintain the Change History.

I've checked the field properties of KNVD and found out Change Document is switched on for NA_KSCHL. So BDC will work.

The issue with BDC recording is it selects the record by line number. Here's the BDC code:

perform bdc_dynpro   using 'SAPMF02D' '0101'.

perform bdc_field       using 'BDC_CURSOR'       'RF02D-D0326'.

perform bdc_field       using 'BDC_OKCODE'       '/00'.

perform bdc_field       using 'RF02D-KUNNR'       '000300-001'.

perform bdc_field       using 'RF02D-VKORG'       'V001'.

perform bdc_field       using 'RF02D-VTWEG'       'V1'.

perform bdc_field       using 'RF02D-SPART'         'V1'.

perform bdc_field       using 'USE_ZAV'                 'X'.

perform bdc_field       using 'RF02D-D0326'            'X'.

perform bdc_dynpro   using 'SAPMF02D' '0326'.

perform bdc_field       using 'BDC_CURSOR'         'KNVD-DOCTP(01)'.

perform bdc_field       using 'BDC_OKCODE'           '=LDEL'.

perform bdc_dynpro    using 'SAPMF02D' '0326'.

perform bdc_field       using 'BDC_CURSOR'             'RF02D-KUNNR'.

perform bdc_field       using 'BDC_OKCODE'             '=UPDA'.

perform bdc_transaction using 'XD02'.

KNVD-DOCTP(01) : Here, how can we pass random line number? I want to select only those records wherein DOCTP = 'ZXY'.

I thought of using 'Search' button ; but it is disabled.

Is there any BAPI to update KNVD entries that also maintains Change History (CDHDR / CDPOS)?

Or how can I solve the line number issue in my above BDC code?

Please do help.

Thanks & Regards,

Sowmya

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Sowmya,

using table control in BDC you can handle ur line number issue .

BDC Example: Using Table Control in BDC

Regard's

Smruti

4 REPLIES 4

Former Member
0 Kudos

Hello All,

While debugging , I found out KNVD-DOCTP(01) will give just 'Z' (1 character) and it is not selecting the line.

Can someone please help me how to achieve this? - BDC to delete KNVD entries based on specific output type.

Pls reply.

Thanks,

Sowmya

Former Member
0 Kudos

Can someone please help me on this?

Thanks,
Sowmya

Former Member
0 Kudos

Hi Sowmya,

using table control in BDC you can handle ur line number issue .

BDC Example: Using Table Control in BDC

Regard's

Smruti

raymond_giuseppi
Active Contributor
0 Kudos

With BDC there is no easy  way,you will have to read  the current records in KNVD, sorted as displayed in transaction, and calculate the index value so field name in BDC, then delete from last to first. You may be also required to use pagination too (ok_code = P=, and subtract page size from index)

Else you could check IDoc DEBMAS or DEBMAS03 which contains KNVD.(may require DIMP, check on your system)

Regards,

Raymond