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: 

Change IKEY on DFKKOP Table

ThamerDoulat
Explorer
0 Kudos
810

I need to update the IKEY field on the DFKKOP table, and I can't find FMs to change this value,

I've checked the following FMs and didn't work correctly:

1. FKK_CHANGE_DOC_DB
2. BAPI_CTRACDOCUMENT_CHANGE
Is there any way to change it instead of physical changing (Update the value directly).
5 REPLIES 5

raymond_giuseppi
Active Contributor
683

AFAIK DFKKOP contains a field IKEY, not BFKKOP?

raymond_giuseppi
Active Contributor
0 Kudos
683

Did you try to use the EXTENSIONIN parameter of BAPI_CTRACDOCUMENT_CHANGE?

(Add required field in structures BAPI_TE_DFKKOPCH and -X)

683

thamer_doulat See official SAP documentation + all answers about EXTENSIONIN. It's the same for any BAPI. It's a basic concept of BAPI.

ThamerDoulat
Explorer
683

This the code that i used to change the value of IKEY using EXTENSIONIN

FORM UPDATE_DB. 

 SELECT * FROM DFKKOP    
WHERE OPBEL IN @SO_OPBEL AND IKEY <> 'Z1'    
INTO TABLE @DATA(GT_ALV).

  LOOP AT GT_ALV ASSIGNING FIELD-SYMBOL(<FS_ALV>) .

    DATA: LT_PARTNERPOSITIONS TYPE STANDARD TABLE OF BAPIDFKKOPCH,          
                LS_PARTNERPOSITIONS TYPE BAPIDFKKOPCH.

    LS_PARTNERPOSITIONS-LINE_NUMBER = <FS_ALV>-OPUPK.
  APPEND LS_PARTNERPOSITIONS TO LT_PARTNERPOSITIONS.    

DATA: IT_EXTENSIONIN TYPE TABLE OF BAPIPAREX,          
              WA_EXTENSIONIN TYPE BAPIPAREX,         
               WA_RETURN      TYPE BAPIRET2.

DATA: WA_IKEY TYPE BAPI_TE_DFKKOPCH,
WA_IKEYX TYPE BAPI_TE_DFKKOPCHX.

WA_IKEY-LINE_NUMBER = <FS_ALV>-OPUPK.
WA_IKEY-IKEY = 'Z1'.

* Populate the ExtensionIn structure with the additional fields
WA_EXTENSIONIN-STRUCTURE = 'BAPI_TE_DFKKOPCH'.
WA_EXTENSIONIN-VALUEPART1 = WA_IKEY.

APPEND WA_EXTENSIONIN TO IT_EXTENSIONIN.

WA_IKEYX-LINE_NUMBER = <FS_ALV>-OPUPK.
WA_IKEYX-IKEY = 'X'.

* Populate the ExtensionIn structure with the additional fields
WA_EXTENSIONIN-STRUCTURE = 'BAPI_TE_DFKKOPCHX'.
WA_EXTENSIONIN-VALUEPART1 = WA_IKEYX.

* Append the structure to a table
APPEND WA_EXTENSIONIN TO IT_EXTENSIONIN.

CALL FUNCTION 'BAPI_CTRACDOCUMENT_CHANGE'
EXPORTING
DOCUMENTNUMBER = <FS_ALV>-OPBEL
* DOCUMENTHEADER =
* DOCUMENTHEADERX =
IMPORTING
RETURN = WA_RETURN
TABLES
PARTNERPOSITIONS = LT_PARTNERPOSITIONS
* PARTNERPOSITIONSX =
* REPETITIONPOSITIONS =
* REPETITIONPOSITIONSX =
* POSITIONLOCKS = LT_POSITIONLOCKS
EXTENSIONIN = IT_EXTENSIONIN
* POSITIONLOCKS_WITH_COMMENT =
.

IF SY-SUBRC = 0.
* Commit the changes
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
ENDIF.

ENDLOOP.
ENDFORM.



WA_RETURN always get this error :   Different line in change parameter 

Can anyone check the code??

0 Kudos
683

I've created new fields in the structures BAPI_TE_DFKKOPCH and BAPI_TE_DFKKOPCHX as the following:

@Raymond Giuseppi