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

Programming posting change in EWM

rob_smeets2
Participant
0 Likes
23,730

Hi folks,

I have the following requirement: create a function module that can perform a posting change in EWM (called up by a background program).

Now I have found the following function module: /SCWM/STOCK_CHANGE, but it is not clear to me how I can fill it up with data. Is there anyone here who knows what function module or method can be used to fill up the import parameters?

When you do the posting change from the UI, all this happens in class /SCWM/CL_UI_POST, but I don't see how I can use parts of this class without the UI elements.

Regards,

Rob

1 ACCEPTED SOLUTION
Read only

rob_smeets2
Participant
0 Likes
15,180

I'm coming back to this question because it is becoming more pressing at this moment: I've identified a couple of likely candidate function modules to do this for me, but alas, neither of them is documented at all (or released, for that matter).

there is /scwm/gm_create, /scwm/gm_post, /scwm/stock_change

I'd be happy with any example code, hints on how to go about this,...

12 REPLIES 12
Read only

rob_smeets2
Participant
0 Likes
15,181

I'm coming back to this question because it is becoming more pressing at this moment: I've identified a couple of likely candidate function modules to do this for me, but alas, neither of them is documented at all (or released, for that matter).

there is /scwm/gm_create, /scwm/gm_post, /scwm/stock_change

I'd be happy with any example code, hints on how to go about this,...

Read only

0 Likes
15,180

Hi,

Even I am struck with the same problem.

Can any one provide me a BAPI or a function module to do the Posting Change in eWM?

The transaction for doing the Posting Change is /SCWM/POST or /SCWM/IM_PC.

I am not able to do a call  transaction for these transactions.

So, could some body provide me a BAPI  or function module for the same.

I am not able to use the FMs /SCWM/STOCK_CHANGE.

Thanks

Madhavi

Read only

0 Likes
15,180

Hi Rob,

We have similar requirement to do posting change from RF

which is not there in standard

Were you able to use the FM /SCWM/STOCK_CHANGE

Regards,

Roopendra

Read only

0 Likes
15,180

Have you guys figured out how to use this FM? I am facing exactly the same issue. Please provide any information that would help.

thanks, Raj

Read only

0 Likes
15,180

HI ,

  I know this is an old post.  Did any of you solve the issue?Can you please share any info if you have solved it?

Regards,

Santosh

Read only

0 Likes
15,180

Hi Santosh,

Sorry, we never did the posting change that way (the requirements changed before I completed my spec and therefore it was never programmed or tested).

I've looked but can't find anything relevant in my notes from that time.

Good luck!

Rob

Read only

0 Likes
15,180

Thanks anyways Rob

Read only

Former Member
15,180

HI All,

   I managed to solve the issue. I used the class  /SCWM/CL_UI_POST to do it.

The Steps are:

  1. instantiate /SCWM/CL_UI_POST ( object LR_UI_POST )
  2.   Initialise /SCMB/CL_EES_DEFAULTS=>init to populate the defaults( Warehouse etc.)
  3.   Populate the defaults using the esdus_manager received from step 2
  4. call METHOD lr_UI_post->('QUERY') to populate the internal table.
  5. Change the internal table to your specifications/needs ( eg:process type ,destination bins etc)
  6. CALL METHOD lr_UI_post->UPDATE to update the details
  7.   call METHOD lr_UI_post->('EXECUTE')
  8. CALL METHOD lr_UI_post->('SAVE')
  9. Commit work and wait


Hope this helps and please change the thread to answered.


Regards,

Santosh


Read only

0 Likes
15,180

Hi Santosh

execute method fails at the check for OIP as it checks for /SCWM/POST. Can you please let me know how did you over come this.

Thanks, Raj

Read only

0 Likes
15,180

Hi Santosh,

Can you please share the sample code if you have for this. We are facing the same issue.

Thanks

Srinivasa

Read only

former_member267257
Discoverer
15,180

Everything is easier. I like that implemented

CALL FUNCTION '/SCWM/STOCK_CHANGE'

          EXPORTING

            is_header   = ls_header

            it_item     = lt_item

          IMPORTING

            et_bapiret  = lt_bapiret

            ev_severity = lv_severity.

CALL FUNCTION '/SCWM/GM_POST'.

commit  work and wait.

Read only

former_member688833
Discoverer
15,180

I had this same exact problem but specifically to update the stock type after a Goods receive what i used was the function module /SCWM/STOCK_CHANGE and /SCWM/GM_POST, i can provide the method i used for modification depending on the requirements.

If the following code adjusted to your requirements doesn't work i recommend opening the transaction SAAB and activate the break point /SCWM/GM, following that do your posting using the transaction /n/SCWM/POST and find the Function module /SCWM/STOCK_CHANGE and see what the Standart code is passing in the importing structures and tables regarding your example, i believe if you change to use just what standart uses as i did in my case it will work.

Good Luck,

Alex.

METHOD update_stock_type.
DATA lt_aqua TYPE STANDARD TABLE OF /scwm/aqua.
DATA it_item TYPE /scwm/tt_spitem.
DATA is_item TYPE /scwm/s_spitem.
DATA lt_bapiret TYPE bapiret2_t.
DATA lv_severity TYPE bapi_mtype.
DATA is_quan TYPE /scwm/s_quan.
DATA lt_ordim_c TYPE STANDARD TABLE OF /scwm/ordim_c.
DATA lv_cat TYPE /lime/stock_category.


"There will be necessary to exist a internal table with the HUs we want to update for my case and for the sake of just showing an example consider it is lt_hus

"gets information regarding the HU on aqua
SELECT *
FROM /scwm/aqua
INTO TABLE lt_aqua
FOR ALL ENTRIES IN lt_hus
WHERE lgnum EQ lv_lgnum
AND huident EQ lt_hus-huident.

IF sy-subrc <> 0.
"Implement your own logic when no data is found

ENDIF.

"Gets the item information updated
SELECT *
FROM /scdl/db_proci_i
INTO TABLE @DATA(lt_proci_update)
WHERE docid EQ @gs_screen_items-proci-docid.

IF sy-subrc <> 0.
CLEAR lt_proci_update.

"Implement your own logic when no data is found

ENDIF.

"Gets the task created for the HU by POSTING
SELECT *
FROM /scwm/ordim_c
INTO TABLE lt_ordim_c
FOR ALL ENTRIES IN lt_ewmt021
WHERE lgnum EQ gs_screen_header-lgnum
AND dguid_hu EQ lt_ewmt021-guid_hu.

IF sy-subrc <> 0.
CLEAR: lt_ewmt021, lt_proci_update, lt_ordim_c.

"Implement your own logic when no data is found

ENDIF.

LOOP AT lt_hus ASSIGNING FIELD-SYMBOL(<fs_hus>).

READ TABLE lt_aqua WITH KEY huident = <fs_hus>-huident ASSIGNING FIELD-SYMBOL(<fs_aqua>).

IF <fs_aqua> IS NOT ASSIGNED.
CONTINUE.
ENDIF.

READ TABLE lt_proci_update WITH KEY docid = <fs_hus>-docid
itemid = <fs_hus>-itemid ASSIGNING FIELD-SYMBOL(<fs_proci>).

IF <fs_proci> IS NOT ASSIGNED.
CONTINUE.
ENDIF.

READ TABLE lt_ordim_c WITH KEY dguid_hu = <fs_hus>-guid_hu ASSIGNING FIELD-SYMBOL(<fs_ordim_c>).

IF <fs_ordim_c> IS NOT ASSIGNED.
CONTINUE.
ENDIF.

"In this case the update will be to change the stock type from blocked to Unblocked
"Stock Type to be updated
MOVE <fs_aqua>-cat TO lv_cat.
REPLACE ALL OCCURRENCES OF 'B' IN lv_cat WITH 'F'.

"Gets QUAN information
SELECT SINGLE *
FROM /scwm/quan
INTO @DATA(ls_quan)
WHERE guid_stock EQ @<fs_aqua>-guid_stock
AND guid_parent EQ @<fs_aqua>-guid_parent.

"Sets the ID using the current line iterator
is_item-id = sy-tabix.
is_item-id_group = sy-tabix + 1.
is_item-direction = 'T'.
is_item-squant_set = abap_true.
is_item-procty = <fs_proci>-/scwm/procty.
is_item-guid_hu = <fs_hus>-guid_hu.
is_item-huident = <fs_hus>-huident.

"Quantity of stock saved on the HU
is_quan-unit = <fs_hus>-uom.
is_quan-quan = <fs_hus>-qty.
APPEND is_quan TO is_item-t_quan.

"Information regarding the HU in the Wharehouse
is_item-loc-lgnum = gs_screen_header-lgnum.
is_item-loc-lgtyp = <fs_aqua>-lgtyp.
is_item-loc-lgpla = <fs_aqua>-lgpla.

"Passes the current information of the HU
is_item-source_s-idx_stock = ls_quan-idx_stock.
is_item-source_s-guid_stock = <fs_aqua>-guid_stock.
is_item-source_s-matid = <fs_aqua>-matid.
is_item-source_s-cat = <fs_aqua>-cat.
is_item-source_s-owner = <fs_aqua>-owner.
is_item-source_s-owner_role = <fs_aqua>-owner_role.
is_item-source_s-entitled = <fs_aqua>-entitled.
is_item-source_s-entitled_role = <fs_aqua>-entitled_role.
is_item-source_s-qdoccat = <fs_proci>-doccat.
is_item-source_s-qdocid = <fs_proci>-docid.
is_item-source_s-qitmid = <fs_proci>-itemid.

"Passes the information with the modifications we want made to the stock
is_item-dest_s-matid = <fs_aqua>-matid.
is_item-dest_s-cat = lv_cat. "What we will want to modifiy
is_item-dest_s-matid = <fs_aqua>-matid.
is_item-dest_s-qdoccat = <fs_proci>-doccat.
is_item-dest_s-qdocid = <fs_proci>-docid.
is_item-dest_s-qitmid = <fs_proci>-itemid.
is_item-dest_s-owner = <fs_aqua>-owner.
is_item-dest_s-owner_role = <fs_aqua>-owner_role.
is_item-dest_s-entitled = <fs_aqua>-entitled.
is_item-dest_s-entitled_role = <fs_aqua>-entitled_role.

APPEND is_item TO it_item.
CLEAR is_item.

ENDLOOP.

"Calls Stock Change function module to proceed to update the HU
CALL FUNCTION '/SCWM/STOCK_CHANGE'
EXPORTING
is_header = VALUE /scwm/s_gmheader( lgnum = gs_screen_header-lgnum
created_by = <fs_ordim_c>-created_by
created_at = <fs_ordim_c>-created_at
code = '/SCWM/POST' )
it_item = it_item
IMPORTING
et_bapiret = lt_bapiret
ev_severity = lv_severity.

LOOP AT lt_bapiret ASSIGNING FIELD-SYMBOL(<fs_bapiret>).

IF <fs_bapiret>-type EQ 'E'.
CALL FUNCTION 'YOUR_MESSAGE_FUNCTION'
EXPORTING
iv_id = <fs_bapiret>-id
iv_number = <fs_bapiret>-number
iv_typ = <fs_bapiret>-type
iv_var1 = <fs_bapiret>-message_v1
iv_var2 = <fs_bapiret>-message_v2
iv_var3 = <fs_bapiret>-message_v3
iv_var4 = <fs_bapiret>-message_v4.
CLEAR: lt_proci_update, lt_ordim_c.
"implementar rotina de erro
ENDIF.

ENDLOOP.

"Will try to POST the changes and for that the function module will generate a new task 
TRY.
DATA lv_tanum TYPE /scwm/tanum.
CALL FUNCTION '/SCWM/GM_POST'
IMPORTING
ev_tanum = lv_tanum
et_bapiret = lt_bapiret
ev_severity = lv_severity.
CATCH /scwm/cx_core.

LOOP AT lt_bapiret ASSIGNING <fs_bapiret>.

IF <fs_bapiret>-type EQ 'E'.
CALL FUNCTION 'YOUR_MESSAGE_FUNCTION'
EXPORTING
iv_id = <fs_bapiret>-id
iv_number = <fs_bapiret>-number
iv_typ = <fs_bapiret>-type
iv_var1 = <fs_bapiret>-message_v1
iv_var2 = <fs_bapiret>-message_v2
iv_var3 = <fs_bapiret>-message_v3
iv_var4 = <fs_bapiret>-message_v4.
CLEAR: lt_proci_update, lt_ordim_c.
"Implement your own logic for when theres an error
ENDIF.

ENDLOOP.

ENDTRY.

COMMIT WORK AND WAIT.

ENDMETHOD.