Modern SAP warehousing (EWM) makes me use old ABAP
I am an ABAP developer.
And you might know that I claim to do “modern” ABAP.
But programming in a modern SAP warehousing solution – SAP EWM – makes me use old ABAP.
Like function modules.
And maybe even dynpros.
An example is the /SCWM/MON: the nodes have to be FMs, the methods as well.
Here is an example monitor method:
FUNCTION Z_MON_METHOD_PAINT_HU IMPORTING IV_LGNUM TYPE /SCWM/LGNUM IT_DATA TYPE /SCWM/TT_LIME_ALL_MON. *Allow just 1 line IF lines( it_data ) <> 1. "Please select exactly 1 line for this method! MESSAGE s003 DISPLAY LIKE 'W'. RETURN. ELSE. DATA(ls_hu_data) = it_data[ 1 ]. ENDIF. *Ask for Input ("what colour to paint the HU?") gs_hu_paint_dynpro-huident = ls_hu_data-huident CALL SCREEN c_screen_paint_HU STARTING AT 10 10 . *make sure no cancel etc. IF g_fcode NE c_fcode_save. RETURN. ENDIF. * do the actual work in ABAP OO: go_my_mon_node->paint_hu_in_colour( i_huident = gs_hu_paint_dynpro-huident i_colour = gs_hu_paint_dynpro-colour_to_paint ). ENDFUNCTION.
You know what: I think it’s not that bad, actually.
What do you think?
Do you use old ABAP?
Do you have to?
FM still alive!
Try to use Try...Catch for ls_hu_data = it_data[ 1 ].
Will make your ABAP little more modern.
And delete the obvious comments for Clean code: Comment why not what
try ... catch there not needed, it is one line in the table
I still use old stuff. Sometimes I'm working on a legacy program - I'll improve it a bit. Much of my work is still using SAPGui as the front end, so I'm still using selection screens, dynpros and function modules. I generally skip off into methods as soon as its possible. I'm pragmatic about it though.
Recently I did something like this
Where screen 200 has a custom container.
Of course I use factory classes to get my concrete classes - but only returning a reference to an interface, and allow all the classes that ZCL_MY_APP use to be injected into its constructor, which makes it easier to write the unit tests.
I do - of course hiding the function calls in methods, because...well...I don't know:
I am a bit curious about your example - from where is the function called, is there a way to add custom buttons/functions in the EWM Monitors?
Yes, there is customizing to add methods to /SCWM/MON :
Screenshot of SPRO: Node Extended Warehouse Management - Monitoring - Warehouse Management Monitor - Define Object Class Methods