on 2022 Dec 20 5:15 AM
Hello all,
Iam able to delete a record from the table person responsible EHFNDD_LOC_RESP.
however i'm unable to create a record.
below is the code im using
FOR DELETE
CALL METHOD /BOBF/CL_TRA_SERV_MGR_FACTORY=>GET_SERVICE_MANAGER
EXPORTING
IV_BO_KEY = IF_EHFND_LOC_C=>SC_BO_KEY
RECEIVING
EO_SERVICE_MANAGER = LO_SERV_MNGR.
CALL METHOD /BOBF/CL_TRA_TRANS_MGR_FACTORY=>GET_TRANSACTION_MANAGER
RECEIVING
EO_TRANSACTION_MANAGER = LO_TXN_MNGR.
LO_SERV_MNGR->QUERY(
EXPORTING
IV_QUERY_KEY =IF_EHFND_LOC_C=>SC_QUERY-RESPONSIBLE-SELECT_BY_ELEMENTS " Query
IV_FILL_DATA = ABAP_TRUE " Data element for domain
IMPORTING
ET_DATA = LT_RESP
ET_KEY = LT_KEY
).
LOOP AT GT_ALV_OUT INTO WA_LOC_ALV WHERE DB_KEY = WA_LOC_ALV-DB_KEY.
CREATE DATA LR_CREATE.
LR_CREATE->PERSON_ID = WA_LOC_ALV-PERSON_ID .
LR_CREATE->KEY = WA_LOC_ALV-DB_KEY .
APPEND INITIAL LINE TO LT_MOD ASSIGNING FIELD-SYMBOL(<LFS_CREATE>).
<LFS_CREATE>-KEY = LR_CREATE->KEY.
<LFS_CREATE>-NODE = IF_EHFND_LOC_C=>SC_NODE-RESPONSIBLE.
<LFS_CREATE>-DATA = LR_CREATE.
<LFS_CREATE>-CHANGE_MODE = 'D'.
LO_SERV_MNGR->MODIFY(
EXPORTING
IT_MODIFICATION = LT_MOD
IMPORTING
EO_CHANGE = LO_CHNG
EO_MESSAGE = LO_MSG
).
LO_TXN_MNGR->SAVE(
IMPORTING
EV_REJECTED = LV_REJ
EO_MESSAGE = LO_MSG_TXN
).
ENDLOOP.
FOR CREATE
CREATE DATA LR_CREATE1.
LR_CREATE1->PERSON_ID = WA_LOC_ALV1-PERSON_ID .
LR_CREATE1->DB_KEY = /BOBF/CL_FRW_FACTORY=>GET_NEW_KEY( ).
LR_CREATE1->PARENT_KEY = LS_LOCREV-DB_KEY .
APPEND INITIAL LINE TO LT_MOD ASSIGNING FIELD-SYMBOL(<LFS_CREATE1>).
<LFS_CREATE1>-KEY = /BOBF/CL_FRW_FACTORY=>GET_NEW_KEY( ).
<LFS_CREATE1>-NODE = IF_EHFND_LOC_C=>SC_NODE-RESPONSIBLE.
<LFS_CREATE1>-NODE = if_ehfnd_loc_c=>sc_association-revision-responsible.
<LFS_CREATE1>-DATA = LR_CREATE1.
<LFS_CREATE1>-CHANGE_MODE = /BOBF/IF_FRW_C=>SC_MODIFY_CREATE.
LO_SERV_MNGR->MODIFY(
EXPORTING
IT_MODIFICATION = LT_MOD
IMPORTING
EO_CHANGE = LO_CHNG
EO_MESSAGE = LO_MSG ).
LO_TXN_MNGR->SAVE(
IMPORTING
EV_REJECTED = LV_REJ
EO_MESSAGE = LO_MSG_TXN
).
KIND REGARDS
Lakshmi
Hi Lakshmi,
when creating the new node instance for the Location BO - Responsible Person, you have to fill the modification table correctly:
In your coding, you're filling the node key to be created with the association key.
With kind regards,
Michael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Michael below is the changed code still it dumps. attached is the association
LOOP AT GT_ALV_OUT1 INTO WA_LOC_ALV1 WHERE DB_KEY = WA_LOC_ALV1-DB_KEY.).
Hi Michael i changed the code as below. unfotunately it didnt work
LOOP AT GT_ALV_OUT1 INTO WA_LOC_ALV1 WHERE DB_KEY = WA_LOC_ALV1-DB_KEY.
SELECT SINGLE * FROM EHFNDD_LOC_ROOT INTO @DATA(LS_LOCROOT)
WHERE ID = @WA_LOC_ALV1-ID.
SELECT SINGLE * FROM EHFNDD_LOC_REV INTO @DATA(LS_LOCREV)
WHERE PARENT_KEY = @LS_LOCROOT-DB_KEY .
CREATE DATA LR_CREATE1.
LR_CREATE1->PERSON_ID = WA_LOC_ALV1-PERSON_ID .
LR_CREATE1->DB_KEY = /BOBF/CL_FRW_FACTORY=>GET_NEW_KEY( ).
LR_CREATE1->PARENT_KEY = LS_LOCREV-DB_KEY .
LR_CREATE1->ROOT_KEY = LS_LOCROOT-DB_KEY .
APPEND INITIAL LINE TO LT_MOD ASSIGNING FIELD-SYMBOL(<LFS_CREATE1>).
<LFS_CREATE1>-KEY = LS_LOCREV-DB_KEY.
<LFS_CREATE1>-NODE = IF_EHFND_LOC_C=>SC_NODE-REVISION.
<LFS_CREATE1>-ASSOCIATION = IF_EHFND_LOC_C=>SC_ASSOCIATION-REVISION-RESPONSIBLE.
<LFS_CREATE1>-DATA = LR_CREATE1.
<LFS_CREATE1>-CHANGE_MODE = /BOBF/IF_FRW_C=>SC_MODIFY_CREATE.
kind regards
lakshmi
Hi Lakshmi,
as I mentioned before, you have to add the right fields to the modification:
Michael
Hi Michael thanks for your patience and response. i have added the below pls let me know if im not correct
READ TABLE LT_RESP INTO DATA(WA_RESP1) WITH KEY PERSON_ID = P_BNAME.
IF SY-SUBRC = 0.
MOVE WA_RESP1-PERSON_ID TO WA_LOC_ALV1-PERSON_ID.
* LV_ROOT_KEY = /BOBF/CL_FRW_FACTORY=>GET_NEW_KEY( ).
MOVE WA_RESP1-PARENT_KEY TO WA_LOC_ALV1-DB_KEY .
ENDIF.
CREATE DATA LR_CREATE1.
LR_CREATE1->PERSON_ID = WA_LOC_ALV1-PERSON_ID .
LR_CREATE1->KEY = WA_LOC_ALV1-DB_KEY.
APPEND INITIAL LINE TO LT_MOD ASSIGNING FIELD-SYMBOL(<LFS_CREATE1>).
<LFS_CREATE1>-KEY = WA_LOC_ALV1-DB_KEY.
source_node (if_ehfnd_loc_c=>sc_node-revision) -> not set yet
<LFS_CREATE1>-NODE = IF_EHFND_LOC_C=>SC_NODE-REVISION.
<LFS_CREATE1>-ASSOCIATION = IF_EHFND_LOC_C=>SC_ASSOCIATION-REVISION-RESPONSIBLE.
<LFS_CREATE1>-DATA = LR_CREATE1.
<LFS_CREATE1>-CHANGE_MODE = /BOBF/IF_FRW_C=>SC_MODIFY_CREATE.
kind regards
lakshmi
Hi Lakshmi,
I'm trying one more time. You are still missing parameters for the modification structure /BOBF/S_FRW_MODIFICATION. This structure has to be filled correctly with the association, source node key, and source key. As shown on the figure below, there are a number of nodes involved in here:
As you are trying to create an instance of the node RESPONSIBLE, the REVISION and the ROOT are of interest, to be more precise, their keys.
For the creation, you will need the following keys:
Now, let's get into the coding. These keys have to be filled:
DATA:
" BOPF Modification
ls_modification TYPE /bobf/s_frw_modification,
" EHS Location BO - Responsible (combined)
lr_s_loc_resp TYPE REF TO ehfnds_loc_responsible.
" first, we create soem data for the responsible person to be assigned to the location
CREATE DATA lr_s_loc_resp.
lr_s_loc_resp->person_id = <Jane Doe>.
lr_s_loc_resp->role = <Industrial Hygienist>.
" now, we can fill the parameters of the modification
ls_modification-data = lr_s_loc_resp.
ls_modification-change_mode = /bobf/if_frw_c=>sc_modify_create.
" which node are we going to create ?
ls_modification-node = if_ehfnd_loc_c=>sc_node-responsible.
" for which ROOT is the node being created ?
ls_modification-root_key = <root key here>.
" for which NODE is the node to be created a child ?
ls_modification-association = if_ehfnd_loc_c=>sc_association-revision-responsible.
ls_modification-source_node = if_ehfnd_loc_c=>sc_node-revision.
ls_modification-source_key = <revision key here>.
" finally, perform the modification...
The important part is (which you were missing), to fully populate the information regarding the association (association key, source node key, and source key). In your example, the direct parent of the node instance to be created is not known. Therefore, the shortdump.
With kind regards,
Michael
Hi Michael i have passed all the below now.
now im getting below error
Info: Attribute REVISION_DESCR does not exist on node REVISION
i have checked the table EHFNDD_LOC_REV for REVISION_DESCR in the table and there is an entry.
Kind Regards
Lakshmi
User | Count |
---|---|
5 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.