Programmatically change the location number (custodian name) in SAP)

Source: Internet
Author: User

This is a previously written sap program. It features real-time driving of the batch input module through the input (Change) interface to process data in the background. The program list is as follows:

Report zbh no standard page heading line-size 95 message-ID z1.
*&---------------------------------------------------------------------&
* Change the account number (XXXX) by Paul Feng (FQ) 2003.07.07
* Ver1.5 last modified 2005.01.10
*&---------------------------------------------------------------------&

Tables: Mara, Makt.
Data: bdcdata like bdcdata occurs 0 with header line.
Data: wzdm (18) type C, BH (18) type C, wlms like MAKT-MAKTX.

Selection-screen begin of block xgbh with frame title text-001.

Selection-screen skip 2.
Select-options: DM for MARA-MATNR no-Extension No intervals obligatory
Memory ID mat.

Selection-screen skip 1.

Selection-screen end of block xgbh.

Start-of-selection.

If not DM-LOW is initial.

Wzdm = DM-LOW.
Call function 'zformatdm'
Changing materialdm = wzdm.

Select single * from Mara where matnr EQ wzdm.

If SY-SUBRC EQ 0.
BH = MARA-BISMT.
Call screen '000000 '.
Else.
Message i079 with DM-LOW.
Endif.
Endif.

End-of-selection.

Form dynpro using dynbegin name value.

If dynbegin = 'x '.
Clear bdcdata.
Move: 'X' to BDCDATA-DYNBEGIN,
Name To BDCDATA-PROGRAM,
Value to BDCDATA-DYNPRO.
Append bdcdata.
Else.
Clear bdcdata.
Move: Name To BDCDATA-FNAM,
Value to BDCDATA-FVAL.
Append bdcdata.
Endif.

Endform.

Module status_0100 output.
Set PF-STATUS 'xgbh '.
Set titlebar '123 '.
Wzdm = DM-LOW.
Shift wzdm Left deleting leading '0 '.
Select single * From Makt where matnr = DM-LOW.
If SY-SUBRC EQ 0.
Wlms = MAKT-MAKTX.
Else.
Wlms = ''.
Endif.

Endmodule. "status_0100 output

Module user_command_0100 input.

If SY-UCOMM EQ 'write '.

If wzdm is initial.
Message e096.

Else.

Call function 'zformatdm'
Changing materialdm = wzdm.
Select single * from Mara where matnr EQ wzdm.
If SY-SUBRC EQ 0.

Perform zbhxg using wzdm BH. "BDC direct input

If SY-SUBRC EQ 0.
Message i131 with 'success! '.
Else.
Message i131 with 'failed! Unknown cause. '.
Endif.
Else.
Shift wzdm Left deleting leading '0 '.
Message e079 with wzdm.
Endif.
Endif.

Endif.

Endmodule. "user_command_0100 Input

Form zbhxg using p_wzdm
P_bh.

Perform bdc_dynpro using 'saplmgmm' '000000 '.
Perform bdc_field using 'bdc _ cursor'
'Rmmg1-matnr '.
Perform bdc_field using 'bdc _ okcode'
'/00 '.
Perform bdc_field using 'rmmg1-matnr 'p_wzdm.

Perform bdc_dynpro using 'saplmgmm' '000000 '.
Perform bdc_field using 'bdc _ cursor'
'Msichtausw-kzsel (01 )'.

Perform bdc_field using 'bdc _ okcode'
'= Entr '.

Perform bdc_field using 'msichtausw-kzsel (01) ''x '.

Perform bdc_dynpro using 'saplmgmm' '000000 '.
Perform bdc_field using 'bdc _ okcode'
'= Bus '.
Perform bdc_field using 'bdc _ cursor'
'Mara-bismt '.
Perform bdc_field using 'Mara-bismt'
P_bh.
Perform bdc_transaction using 'mm02 '.

Endform. "zbhxg

Form bdc_dynpro using program dynpro.
Clear bdcdata.
BDCDATA-PROGRAM = program.
BDCDATA-DYNPRO = dynpro.
BDCDATA-DYNBEGIN = 'x '.
Append bdcdata.
Endform.

Form bdc_field using FNAM fval.
If fval <> '/'.
Clear bdcdata.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = fval.
Append bdcdata.
Endif.
Endform.

Form bdc_transaction using tcode.
Tables: t100.
Data: messtab like bdcmsgcoll occurs 0 with header line.
Data: ctumode like CTU_PARAMS-DISMODE value 'n '.
Data: cupdate like CTU_PARAMS-UPDMODE value 'l '.
Data: e_group (12), e_group_opened.
Data: e_user (12), e_keep (1) Type C value ''." Not keep session
Data: e_hdate like SY-DATUM.

Data: l_mstring (480 ).
Data: l_subrc like SY-SUBRC.
Refresh messtab.
Call transaction tcode using bdcdata
Mode ctumode
Update cupdate
Messages into messtab.
Rochelle subrc = SY-SUBRC.

Loop at messtab.
Select single * From t100 where sprsl = MESSTAB-MSGSPRA
& Arbgb = MESSTAB-MSGID
And msgnr = MESSTAB-MSGNR.
If SY-SUBRC = 0.
Rochelle mstring = T100-TEXT.
If l_mstring CS '& 1 '.
Replace '& 1' with MESSTAB-MSGV1 into l_mstring.
Replace '& 2' with MESSTAB-MSGV2 into l_mstring.
Replace '& 3' with MESSTAB-MSGV3 into l_mstring.
Replace '& 4' with MESSTAB-MSGV4 into l_mstring.
Else.
Replace '&' with MESSTAB-MSGV1 into l_mstring.
Replace '&' with MESSTAB-MSGV2 into l_mstring.
Replace '&' with MESSTAB-MSGV3 into l_mstring.
Replace '&' with MESSTAB-MSGV4 into l_mstring.
Endif.
Condense l_mstring.
Write:/MESSTAB-MSGTYP, l_mstring (250 ).
Else.
Write:/messtab.
Endif.
Endloop.
Skip.

If l_subrc <> 0 and e_group <> space.
If e_group_opened = ''.
Call function 'bdc _ open_group'
Exporting client = SY-MANDT
Group = e_group
User = e_user
Keep = e_keep
Holddate = e_hdate.
E_group_opened = 'x '.
Endif.
Call function 'bdc _ insert'
Exporting tcode = tcode
Tables dynprotab = bdcdata.
Endif.
Refresh bdcdata.
Clear t100.
Endform.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.