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

[SOLVED] Entry Time for Manual Reservation (MB21)

dukejib5
Participant
0 Likes
5,681

Hello Gurus,

There is a requirement to add timestamp at item level in reservation.

I've added field cputm to a structure and appended it to table RESB.

I've tried to pass on sy-timlo to cputm in several places,but i am unable to get the value.

I've tried the following enhancement spots;

MBCF0007,MBCF0010

BADI's;

MB_RESERVATION_BADI, MB_RES_BAPI_CREATE1 , MB_RESERVATION_UPCHD

Followed these and several others;

https://answers.sap.com/questions/8058214/regarding-mbreservationbadi.html

https://answers.sap.com/questions/7052013/field-enhancement-in-reservation.html

https://blogs.sap.com/2018/09/05/vendor-code-addition-in-mb21-screen/

https://answers.sap.com/questions/2636610/mb21-reservation.html

I've done couple of enhancements before in mb52 & me21n as well, but this is getting out of hand

Update-2:

Create an FM, which receives rsnum and updates Resb.

However, it runs only once, not every time. Made it "Update Module" but it isn't working

TABLES: resb.<br> DATA:itab TYPE TABLE OF resb.<br> DATA:wtab TYPE resb.<br> <br> DATA: lv_1 TYPE rkpf-rsnum.<br> SELECT rsnum FROM resb UP TO 1 ROWS INTO lv_1 WHERE rsnum = IMP_RSNUM.<br> ENDSELECT.<br> <br> Select * INTO TABLE itab from resb where rsnum = IMP_RSNUM.<br> LOOP AT itab INTO wtab.<br> wtab-cputm = sy-timlo.<br> wtab-lgort = '1017'.<br> * MODIFY TABLE resb TRANSPORTING cputm.<br> MODIFY resb FROM wtab.<br> ENDLOOP.<br> <br> BREAK-POINT. 

UPDATE-1:

Function Exit_SAPMM07R_001 looks like the best choice, as it is the last one called after save button pressed.

However, I don't know how to update the value in Tables. (Several tries in below code)

*DATA: wa_resb TYPE resb.<br> *<br> *LOOP AT TI_RESB_NEW INTO wa_resb.<br> * wa_resb-cputm = sy-timlo.<br> * MODIFY TI_RESB_NEW FROM wa_resb TRANSPORTING cputm.<br> *ENDLOOP.<br> <br> *FIELD-SYMBOLS: <fs> TYPE resb.<br> *<br> *LOOP AT TI_RESB_NEW ASSIGNING <fs>.<br> * <fs>-cputm = '232200'.<br> *ENDLOOP.<br> <br> *LOOP AT TI_RESB_NEW.<br> * TI_RESB_NEW-CPUTM = sy-timlo.<br> * MODIFY TI_RESB_NEW.<br> *ENDLOOP.<br> *LOOP AT TI_RESB_OLD.<br> * TI_RESB_OLD-CPUTM = sy-timlo.<br> * MODIFY TI_RESB_OLD.<br> *ENDLOOP.

Your guidance is highly appreciated.

Regards,

[SOLUTION]

Append Structure to RESB with your required fields.

In my case, i added CPUTM field.

Enhance FM MB_RESERVATION_CREATE

Added following code in your enhancement:

This will add timestamp item wise.

Hello Gurus,

There is a requirement to add timestamp at item level in reservation.

I've added field cputm to a structure and appended it to table RESB.

I've tried to pass on sy-timlo to cputm in several places,but i am unable to get the value.

I've tried the following enhancement spots;

MBCF0007,MBCF0010

BADI's;

MB_RESERVATION_BADI, MB_RES_BAPI_CREATE1 , MB_RESERVATION_UPCHD

Followed these and several others;

https://answers.sap.com/questions/8058214/regarding-mbreservationbadi.html

https://answers.sap.com/questions/7052013/field-enhancement-in-reservation.html

https://blogs.sap.com/2018/09/05/vendor-code-addition-in-mb21-screen/

https://answers.sap.com/questions/2636610/mb21-reservation.html

I've done couple of enhancements before in mb52 & me21n as well, but this is getting out of hand

Update-2:

Create an FM, which receives rsnum and updates Resb.

However, it runs only once, not every time. Made it "Update Module" but it isn't working

TABLES: resb.<br> DATA:itab TYPE TABLE OF resb.<br> DATA:wtab TYPE resb.<br> <br> DATA: lv_1 TYPE rkpf-rsnum.<br> SELECT rsnum FROM resb UP TO 1 ROWS INTO lv_1 WHERE rsnum = IMP_RSNUM.<br> ENDSELECT.<br> <br> Select * INTO TABLE itab from resb where rsnum = IMP_RSNUM.<br> LOOP AT itab INTO wtab.<br> wtab-cputm = sy-timlo.<br> wtab-lgort = '1017'.<br> * MODIFY TABLE resb TRANSPORTING cputm.<br> MODIFY resb FROM wtab.<br> ENDLOOP.<br> <br> BREAK-POINT. 

UPDATE-1:

Function Exit_SAPMM07R_001 looks like the best choice, as it is the last one called after save button pressed.

However, I don't know how to update the value in Tables. (Several tries in below code)

*DATA: wa_resb TYPE resb.<br> *<br> *LOOP AT TI_RESB_NEW INTO wa_resb.<br> * wa_resb-cputm = sy-timlo.<br> * MODIFY TI_RESB_NEW FROM wa_resb TRANSPORTING cputm.<br> *ENDLOOP.<br> <br> *FIELD-SYMBOLS: <fs> TYPE resb.<br> *<br> *LOOP AT TI_RESB_NEW ASSIGNING <fs>.<br> * <fs>-cputm = '232200'.<br> *ENDLOOP.<br> <br> *LOOP AT TI_RESB_NEW.<br> * TI_RESB_NEW-CPUTM = sy-timlo.<br> * MODIFY TI_RESB_NEW.<br> *ENDLOOP.<br> *LOOP AT TI_RESB_OLD.<br> * TI_RESB_OLD-CPUTM = sy-timlo.<br> * MODIFY TI_RESB_OLD.<br> *ENDLOOP.

Your guidance is highly appreciated.

Regards,

[SOLUTION]

Append Structure to RESB with your required fields.

In my case, i added CPUTM field.

Enhance FM MB_RESERVATION_CREATE

Added following code in your enhancement:

This will add timestamp item wise.

8 REPLIES 8
Read only

venkateswaran_k
Active Contributor
0 Likes
5,282

Hi

Check this link. It has some ways to update.

https://answers.sap.com/questions/11861349/how-to-update-custom-fields-for-resb-and-afvc-tabl.html

Also check this

BAdI MB_RESERVATION_BADI,

Method DATA_MODIFY

regards,

Venkat

Read only

0 Likes
5,281

Thanks Venkat.

I am already there.

Problem is , in MB_RESERVATION_BADI~DATA-MODIFY, I am unable to update the IT_CHANGEABLE (Type TDTAB_C132) to add my custom field, which will be updated once it's in IT_CHANGEABLE. Also, i don't know how to work with reference type.

Can you guide me for the same?

problem.jpg

Read only

ashar9225
Explorer
0 Likes
5,280

In RESB table standard field BDZTP for time is available. Please check it.

Read only

0 Likes
5,280

This field is for when the item is required. Not when the Reservation was created.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
5,280

Any reason not to use RBKP-CPUDT and CPUTM, what did you already try?

Did you try to use some implicit enhancement at start of

MB_CREATE_RESERVATION, MB_CHANGE_RESERVATION, etc.

Else did you try some tricks using following P&S BTE (Z) (those are called in the previous update FM)

01000501 APO Plug-In: Change Reservation
01000504 APO Plug-In: Create Reservation
01000505 APO Plug-In: Delete Reservation
01000506 APO Plug-In: Change Reservation
Look for call of OUTBOUND_CALL_01000501_E and similar FM


NB: BAdI MB_RESERVATION_BADI only allows displayed and input-allowed fields, based on LOOP AT SCREEN, you have to add a field to dynpros to use the MODIFY method or use some implicit Enhancement spots...


NB: EXIT_SAPMM07R_001 of Enhancement MBCF0007 is executed after update

Read only

dukejib5
Participant
0 Likes
5,280

Thank you for your reply.

1- RBKP doesn't have CPUDT or CPUTM, that's why appended CPUTM.

2- Both MB_CREATE_RESERVATION, MB_CHANGE_RESERVATION are new to me. Tried to find them via SE84 , using MM* as application component, but received no search result.

SE18 & SE19 shows, they are no badi or enhancements by these above names

3- Tried both MB_RESERVATION_BADI & MBCF0007 and some other BADI, but unable to get any result appending time to CPUTM in RBKP. However, i've following code, that works in MBCF0007 and updated a ztable

TABLES: ZRESB_CPUTM.
DATA:itab TYPE TABLE OF ZRESB_CPUTM.
DATA:wtab TYPE ZRESB_CPUTM.
DATA: lv_1 TYPE rkpf-rsnum. SELECT rsnum FROM resb UP TO 1 ROWS INTO @lv_1 WHERE rsnum = @TI_RKPF-rsnum . ENDSELECT.
Select mandt,rsnum,cputm, matnr, rspos INTO TABLE @itab from resb where rsnum = @TI_RKPF-rsnum .
LOOP AT itab INTO wtab.
wtab-cputm = sy-timlo.
* MODIFY TABLE ZRESB_CPUTM TRANSPORTING cputm.
INSERT ZRESB_CPUTM FROM wtab.
ENDLOOP.
Read only

RaymondGiuseppi
Active Contributor
5,280

2- Both MB_CREATE_RESERVATION, MB_CHANGE_RESERVATION are new to me. Tried to find them via SE84 , using MM* as application component, but received no search result

Those are the update task FMs (function group MBRE) that create and change the reservations in database, you could use implicit enhancement to force some timestamp at creation/update (there are also some _ARRAY FM but not related to standard transaction but to some mass update)

NB: We can find a BAdI ,MB_RESERVATION_UPCHD, in those, alas it's reserved for SAP usage 😞

Read only

dukejib5
Participant
0 Likes
5,280
raymond.giuseppi

Thanks a lot. FM MB_CREATE_RESERVATION did the trick.