*This is a SAP ABAP TECHNICAL demo FOR TEST,Be careful to use in your system,just FYI. Create Reservation
*If you have any solution,Please feel free to talk with your IT team/SAP ABAP professional guys. Create Reservation
*This method enables you to create reservations.
*
*The following authorization objects are checked with activity 01
*(Create):
*
*<DS:UO.M_MRES_BWA>M_RES_BWA,,Reservations: movement type
*<DS:UO.M_MRES_WWA>M_MRES_WWA,,Reservations: plant
*The header data of the reservation is passed on in the parameter
*<ZH>ReservationHeader. At least the following data is necessary:
*Movement type (MOVE_TYPE field)
*If account assignment is defined for the movement type, the account
*assignment object (e.g. the cost center in the field COST_CTR)
*Base date (RES_DATE field)
*The item data is passed on in the table <LS>ReservationItems. At
*least the following data is necessary:
*Plant (PLANT field)
*Material number (MATERIAL field)
*Storage location (STORE_LOC field)
*Quantity (QUANTITY field)
*The reservation number is returned in the parameter <LS>Reservation.
*INCLUDE BAPI_RET
*INCLUDE BAPI_INVENTUR_WEITERINF LANGUAGE EN
REPORT ZDEMO_BAPI_RESERVATION_CREATE.
PARAMETERS SAMPLE AS CHECKBOX.
INITIALIZATION.
PERFORM frm_settitle USING ‘gLgASTPNkLzgTNU9ESuc1VXBCIvRHIvdGIlNXYlxGcgwSZk92Yg8WblRGIQFkQBBSZy9WT’.
START-OF-SELECTION.
BREAK-POINT..
**********************************************************************
*******Defination of Work Area Structrue [Import]-[RESERVATION_HEADER ] . “”Transfer Structure: Create Reservation Header
**********************************************************************
DATA: LS_RESERVATION_HEADER TYPE BAPIRKPFC . “”Transfer Structure: Create Reservation Header
LS_RESERVATION_HEADER-RES_NO = ‘NUMC10’. “Reservation
LS_RESERVATION_HEADER-PLANT = ‘CHAR4’. “Plant
LS_RESERVATION_HEADER-RES_DATE = ‘20241208’. “Base date
LS_RESERVATION_HEADER-CREATED_BY = ‘CHAR12’. “User Name
LS_RESERVATION_HEADER-MOVE_TYPE = ‘CHAR3’. “Movement Type
LS_RESERVATION_HEADER-GR_RCPT = ‘CHAR12’. “Goods Recipient
LS_RESERVATION_HEADER-COST_CTR = ‘CHAR10’. “Cost Center
LS_RESERVATION_HEADER-ASSET_NO = ‘CHAR12’. “Asset
LS_RESERVATION_HEADER-SUB_NUMBER = ‘CHAR4’. “Sub-number
LS_RESERVATION_HEADER-ORDER_NO = ‘CHAR12’. “Order
LS_RESERVATION_HEADER-SD_DOC = ‘CHAR10’. “Sales Order
LS_RESERVATION_HEADER-SDOC_ITEM = ‘NUMC6’. “Sales Order Item
LS_RESERVATION_HEADER-SCHED_LINE = ‘NUMC4’. “Sales order schedule
LS_RESERVATION_HEADER-CO_AREA = ‘CHAR4’. “Controlling Area
LS_RESERVATION_HEADER-PART_AREA = ‘CHAR4’. “Trading Part.BA
LS_RESERVATION_HEADER-RL_EST_KEY = ‘CHAR8’. “Real Estate Key
LS_RESERVATION_HEADER-COST_OBJ = ‘CHAR12’. “Cost Object
LS_RESERVATION_HEADER-PROF_SEGM = ‘NUMC10’. “Profitab. Segmt No.
LS_RESERVATION_HEADER-PROFIT_CTR = ‘CHAR10’. “Profit Center
LS_RESERVATION_HEADER-WBS_ELEM_E = ‘CHAR24’. “WBS Element
LS_RESERVATION_HEADER-NETWORK = ‘CHAR12’. “Network
LS_RESERVATION_HEADER-ROUTING_NO = ‘NUMC10’. “Opertn task list no.
LS_RESERVATION_HEADER-COUNTER = ‘NUMC8’. “Counter
LS_RESERVATION_HEADER-PART_ACCT = ‘CHAR10’. “Partner
LS_RESERVATION_HEADER-CMMT_ITEM = ‘CHAR14’. “Commitment item
LS_RESERVATION_HEADER-REC_IND = ‘CHAR2’. “Recovery Indicator
LS_RESERVATION_HEADER-FUNC_AREA = ‘CHAR4’. “Functional Area
LS_RESERVATION_HEADER-G_L_ACCT = ‘CHAR10’. “G/L Account
LS_RESERVATION_HEADER-MOVE_PLANT = ‘CHAR4’. “Receiving plant
LS_RESERVATION_HEADER-MOVE_STLOC = ‘CHAR4’. “Receiving stor. loc.
LS_RESERVATION_HEADER-ACTIVITY = ‘CHAR4’. “Activity
DATA: LV_NO_COMMIT TYPE CHAR1 .”Obligatory
DATA: LV_MOVEMENT_AUTO TYPE MOVEMENT_AUTO .”Obligatory”Use Goods Movement Indicator from Customizing
DATA: LV_RESERVATION TYPE BAPIRKPFC-RES_NO .”Obligatory
**********************************************************************
*******Defination of [Tables]-[RESERVATION_ITEMS] .
**********************************************************************
DATA: LT_RESERVATION_ITEMS TYPE STANDARD TABLE OF BAPIRESBC.””Transfer Structure: Create Reservation Item
DATA: LS_RESERVATION_ITEMS TYPE BAPIRESBC .””Transfer Structure: Create Reservation Item
LS_RESERVATION_ITEMS-MATERIAL = ‘CHAR18’. “Material
LS_RESERVATION_ITEMS-PLANT = ‘CHAR4’. “Plant
LS_RESERVATION_ITEMS-STORE_LOC = ‘CHAR4’. “Storage Location
LS_RESERVATION_ITEMS-BATCH = ‘CHAR10’. “Batch
LS_RESERVATION_ITEMS-QUANTITY = ‘QUAN13’. “Qty in unit of entry
LS_RESERVATION_ITEMS-UNIT = ‘UNIT3’. “Unit of Entry
LS_RESERVATION_ITEMS-REQ_DATE = ‘20241208’. “Requirements date
LS_RESERVATION_ITEMS-G_L_ACCT = ‘CHAR10’. “G/L Account
LS_RESERVATION_ITEMS-SHORT_TEXT = ‘CHAR50’. “Text
LS_RESERVATION_ITEMS-GR_RCPT = ‘CHAR12’. “Goods Recipient
LS_RESERVATION_ITEMS-UNLOAD_PT = ‘CHAR25’. “Unloading Point
LS_RESERVATION_ITEMS-FIXED_QUAN = ‘CHAR1’. “Quantity is fixed
LS_RESERVATION_ITEMS-MOVEMENT = ‘CHAR1’. “Movement allowed
LS_RESERVATION_ITEMS-PROCESS_ID = ‘CHAR1’. “Processing indicator
LS_RESERVATION_ITEMS-MATERIAL_EXTERNAL = ‘CHAR40’. “Material Number
LS_RESERVATION_ITEMS-MATERIAL_GUID = ‘CHAR32’. “GUID (External)
LS_RESERVATION_ITEMS-MATERIAL_VERSION = ‘CHAR10’. “Version Number
LS_RESERVATION_ITEMS-MATERIAL_LONG = ‘CHAR40’. “Material
APPEND LS_RESERVATION_ITEMS TO LT_RESERVATION_ITEMS .
CLEAR LS_RESERVATION_ITEMS .
**********************************************************************
*******Defination of [Tables]-[RETURN] .
**********************************************************************
DATA: LT_RETURN TYPE STANDARD TABLE OF BAPIRETURN.””Return Parameter
DATA: LS_RETURN TYPE BAPIRETURN .””Return Parameter
LS_RETURN-TYPE = ‘CHAR1’. “Message type
LS_RETURN-CODE = ‘CHAR5’. “Message code
LS_RETURN-MESSAGE = ‘CHAR220’. “Message Text
LS_RETURN-LOG_NO = ‘CHAR20’. “Log Number
LS_RETURN-LOG_MSG_NO = ‘NUMC6’. “Message Serial No.
LS_RETURN-MESSAGE_V1 = ‘CHAR50’. “Message Variable
LS_RETURN-MESSAGE_V2 = ‘CHAR50’. “Message Variable
LS_RETURN-MESSAGE_V3 = ‘CHAR50’. “Message Variable
LS_RETURN-MESSAGE_V4 = ‘CHAR50’. “Message Variable
APPEND LS_RETURN TO LT_RETURN .
CLEAR LS_RETURN .
**********************************************************************
*******CallUp The Function Now. .
**********************************************************************
CALL FUNCTION ‘BAPI_RESERVATION_CREATE’
EXPORTING
RESERVATION_HEADER = LS_RESERVATION_HEADER
* NO_COMMIT = LV_NO_COMMIT
* MOVEMENT_AUTO = LV_MOVEMENT_AUTO
IMPORTING
RESERVATION = LV_RESERVATION
TABLES
RESERVATION_ITEMS = LT_RESERVATION_ITEMS
* RETURN = LT_RETURN
EXCEPTIONS
OTHERS = 1
.
BREAK-POINT…
IF sy-subrc <> 0.
*Implement suitable error handling here
ENDIF.
FORM frm_settitle USING uv_old .
DATA lv_ret_s TYPE c LENGTH 200.
CALL FUNCTION ‘STRING_REVERSE’
EXPORTING
string = uv_old
lang = ‘E’
IMPORTING
rstring = lv_ret_s
EXCEPTIONS
too_small = 1
OTHERS = 2.
DATA lv_astring TYPE string.
lv_astring = lv_ret_s.
DATA lv_xs TYPE xstring.
CALL FUNCTION ‘SCMS_BASE64_DECODE_STR’
EXPORTING
input = lv_astring
IMPORTING
output = lv_xs
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
RETURN.
ENDIF.
DATA lt_str TYPE STANDARD TABLE OF solix.
DATA lv_i TYPE i.
CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’
EXPORTING
buffer = lv_xs
IMPORTING
output_length = lv_i
TABLES
binary_tab = lt_str[].
CHECK NOT lt_str[] IS INITIAL.
DATA lv_long TYPE string.
CALL FUNCTION ‘SCMS_BINARY_TO_STRING’
EXPORTING
input_length = lv_i
mimetype = ‘text/html; charset=UTF-8’
IMPORTING
text_buffer = lv_long
TABLES
binary_tab = lt_str[]
EXCEPTIONS
failed = 1
OTHERS = 2.
sy-title = lv_long.
ENDFORM.
If you have problem, please fell free to contact.Thanks.
This post is come from www.hot583.com, you can share/use it with the post original link for free.
But pay attention of any risk yourself.
http://www.hot583.com/category/sap_tech/sap_bapi/
微信原文《The End》