cancel
Showing results for 
Search instead for 
Did you mean: 

Need help to create a record in EHFNDD_LOC_RESP table.

0 Kudos
474

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


rarunac1
Member
0 Kudos

can you check your permission level?

0 Kudos

yes i'm able to create via portal and also via BOBT transaction however via this code i'm getting dump.

The current application program has detected a situation that should

not occur. A termination with short dump has therefore been triggered

by the key word MESSAGE (type X).

raymond_giuseppi
Active Contributor
0 Kudos

What was the error raised/information provided in the dump (message type X -> ST22)

View Entire Topic
michaelf_
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Lakshmi,

when creating the new node instance for the Location BO - Responsible Person, you have to fill the modification table correctly:

  • An association has to be provided (if_ehfnd_loc_c=>sc_association-revision-responsible)
  • A source node key has to be provided (if_ehfnd_loc_c=>sc_node-revision)
  • A source key has to be provided (key of the revision).

In your coding, you're filling the node key to be created with the association key.

With kind regards,

Michael

0 Kudos

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.
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 .
APPEND INITIAL LINE TO LT_MOD ASSIGNING FIELD-SYMBOL(<LFS_CREATE1>).
<LFS_CREATE1>-KEY = IF_EHFND_LOC_C=>SC_NODE-REVISION.
<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 association.png

).

0 Kudos

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

michaelf_
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Lakshmi,

as I mentioned before, you have to add the right fields to the modification:

  • association (if_ehfnd_loc_c=>sc_association-revision-responsible) -> set correctly
  • source_node (if_ehfnd_loc_c=>sc_node-revision) -> not set yet
  • source_key (key of the the revision / parent node of the responsible to be created) -> not set

Michael

0 Kudos

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>).

  • source_key (key of the the revision / parent node of the responsible to be created) -> not set

<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

michaelf_
Product and Topic Expert
Product and Topic Expert
0 Kudos

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:

  • Key of the ROOT instance / Parent key of the REVISION instance
  • Key of the REVISION instance
  • Key of the association from REVISION to RESPONSIBLE
  • Node Key of REVISION as source of the association.

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

0 Kudos

Hi Michael i have passed all the below now.

  • An association has to be provided (if_ehfnd_loc_c=>sc_association-revision-responsible)
  • A source node key has to be provided (if_ehfnd_loc_c=>sc_node-revision)
  • A source key has to be provided (key of the revision).

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

michaelf_
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Lakshmi,

I'm not sure where this error comes from. If the field is correctly populated, there should be no issues. If there are any custom validations, etc. in your system, you might run into this issue.

Michael

0 Kudos

Thanks for your the detailed information Michael it works great .