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

Fill transaction fields automatically through code

xt_inergo
Participant
0 Likes
1,741

Hi Gurus,

Every time we create a material we have to extend it in all plants and in all storage location of every plant.

The steps that we are using are: We first create the material to a plant and a storage location using transaction

MM01. Then we use transaction mm17 and we extend the materials in all plants automatically.

Then we use transaction MMSC to extend material to every storage location. We enter the material code, the plant code and after hitting enter we fill the fields with the storage locations of the plant where we want to extend material to. We have 9 plants and 3 storage location on every plant, so we do this procedure (mmsc) 9 x 3 = 27 times.

Is there a way to write code to fill automatically the fields in MMSC transcaction from a file so that can automate the procedure? Any Ideas how to start?

Thank you in advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,290

Hi!

Here's an example of this stuff, 100% working, but of course you have to change the BDC part for your code...

REFRESH: gt_bdcdata.
      PERFORM bdc_dynpro      USING 'ZMFI_AA_KTGH' '9502'.
      PERFORM bdc_field       USING 'BDC_OKCODE' '=ENTER'.
      PERFORM bdc_field       USING 'ANLZ-KOSTL' gs_change_asset-kostl.
      PERFORM bdc_field       USING 'ANLZ-ADATU' gs_change_asset-bdatu.
      PERFORM bdc_field       USING 'ANLZ-PERNR' gs_change_asset-pernr.
      PERFORM bdc_field       USING 'ANLZ-STADT' gs_change_asset-stadt.
      PERFORM bdc_field       USING 'ANLZ-XSTIL' gs_change_asset-xstil.
      PERFORM bdc_field       USING 'ANLZ-RAUMN' gs_change_asset-raumn.

      PERFORM bdc_dynpro      USING 'ZMFI_AA_KTGH' '9502'.
      PERFORM bdc_field       USING 'BDC_OKCODE' 'DUMMY_OK_CODE'.

      MOVE 'E' TO lv_mode.
      CALL TRANSACTION 'ZMFIAA_MOD' USING gt_bdcdata
                                         MODE lv_mode.

It is very important to give a 'DUMMY_OK_CODE' where you wanted to stop the processing. It is because the dummy ok code will cause a BDC error and the process will stop there and you'll get back the control.

Regards

Tamá

5 REPLIES 5
Read only

xt_inergo
Participant
0 Likes
1,290

I have start writing an abap program using the following code:

CALL TRANSACTION 'MMSC' AND SKIP FIRST SCREEN.

SET parameter ID 'MAT' FIELD zmatnr. "field in first screen

SET parameter ID 'WRK' FIELD '1100'. "field in first screen

SET parameter ID 'LAG' FIELD '1120'. "field in second screen

In the second screen there are many fields with the same parameter id 'LAG'. I can't pass values to second screen probably because there are many fields with the same parameter id.

Can you help?

how can I save the transaction at the end?

Thanks.

Read only

Former Member
0 Likes
1,290

Hello,

If you find that you will have to use CALL TRANSACTION with fields that have no parameter id or same parameter id for different fields, you could probably try creating a partical BDC recording the transaction till the point where user interaction is required and using the mode 'E'.

Vikranth

Read only

0 Likes
1,290

Thanks for your answer,

can you be more specific.

Thanks.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,290

You can use BAPI_MATERIAL_SAVEDATA

Read only

Former Member
0 Likes
1,291

Hi!

Here's an example of this stuff, 100% working, but of course you have to change the BDC part for your code...

REFRESH: gt_bdcdata.
      PERFORM bdc_dynpro      USING 'ZMFI_AA_KTGH' '9502'.
      PERFORM bdc_field       USING 'BDC_OKCODE' '=ENTER'.
      PERFORM bdc_field       USING 'ANLZ-KOSTL' gs_change_asset-kostl.
      PERFORM bdc_field       USING 'ANLZ-ADATU' gs_change_asset-bdatu.
      PERFORM bdc_field       USING 'ANLZ-PERNR' gs_change_asset-pernr.
      PERFORM bdc_field       USING 'ANLZ-STADT' gs_change_asset-stadt.
      PERFORM bdc_field       USING 'ANLZ-XSTIL' gs_change_asset-xstil.
      PERFORM bdc_field       USING 'ANLZ-RAUMN' gs_change_asset-raumn.

      PERFORM bdc_dynpro      USING 'ZMFI_AA_KTGH' '9502'.
      PERFORM bdc_field       USING 'BDC_OKCODE' 'DUMMY_OK_CODE'.

      MOVE 'E' TO lv_mode.
      CALL TRANSACTION 'ZMFIAA_MOD' USING gt_bdcdata
                                         MODE lv_mode.

It is very important to give a 'DUMMY_OK_CODE' where you wanted to stop the processing. It is because the dummy ok code will cause a BDC error and the process will stop there and you'll get back the control.

Regards

Tamá