TCODE CO07 SAMPLE DEMO example BAPI_PRODORD_CREATE

*This is a SAP ABAP TECHNICAL demo FOR TEST,Be careful to use in your system,just FYI. BAPI: Generate Production Order
*If you have any solution,Please feel free to talk with your IT team/SAP ABAP professional guys. BAPI: Generate Production Order
*INCLUDE COBAPI_CREATE OBJECT DOKU ID TX
*INCLUDE COBAPI_CREATE_CHANGE_COMMON OBJECT DOKU ID TX

 

REPORT ZDEMO_BAPI_PRODORD_CREATE.
PARAMETERS SAMPLE AS CHECKBOX.
INITIALIZATION.
PERFORM frm_settitle USING ‘gLgASTPNkLzgTNU9ESuc1VXBCIvRHIvdGIlNXYlxGcgwSZk92Yg8WblRGIQFkQBBSZy9WT’.
START-OF-SELECTION.
BREAK-POINT..

**********************************************************************
*******Defination of Work Area Structrue [Import]-[ORDERDATA ] . “”Transfer Structure for Creating Production Orders
**********************************************************************
DATA: LS_ORDERDATA TYPE BAPI_PP_ORDER_CREATE . “”Transfer Structure for Creating Production Orders
LS_ORDERDATA-ORDER_NUMBER = ‘CHAR12’. “Order
LS_ORDERDATA-MATERIAL = ‘CHAR18’. “Material Number
LS_ORDERDATA-PLANT = ‘CHAR4’. “Plant
LS_ORDERDATA-PLANNING_PLANT = ‘CHAR4’. “Planning Plant
LS_ORDERDATA-ORDER_TYPE = ‘CHAR4’. “Order Type
LS_ORDERDATA-BASIC_START_DATE = ‘20241208’. “Basic start date
LS_ORDERDATA-BASIC_START_TIME = ‘002353’. “Basic start time
LS_ORDERDATA-BASIC_END_DATE = ‘20241208’. “Basic finish date
LS_ORDERDATA-BASIC_END_TIME = ‘002353’. “Basic Finish Time
LS_ORDERDATA-QUANTITY = ‘QUAN13’. “Total Order Quantity
LS_ORDERDATA-SCRAP_QUANTITY = ‘QUAN13’. “Total Scrap Quantity
LS_ORDERDATA-QUANTITY_UOM = ‘UNIT3’. “Unit of measure
LS_ORDERDATA-ROUTING_TYPE = ‘CHAR1’. “Task List Type
LS_ORDERDATA-ROUTING_GROUP = ‘CHAR8’. “Group
LS_ORDERDATA-ROUTING_COUNTER = ‘CHAR2’. “Group Counter
LS_ORDERDATA-PROD_VERSION = ‘CHAR4’. “Production Version
LS_ORDERDATA-EXPLOSION_DATE = ‘20241208’. “BOM Explosion Date
LS_ORDERDATA-ORDER_PRIORITY = ‘CHAR1’. “Priority
LS_ORDERDATA-MRP_CONTROLLER = ‘CHAR3’. “MRP controller
LS_ORDERDATA-CONFIGURATION = ‘NUMC18’. “Internal object no.
LS_ORDERDATA-WBS_ELEMENT = ‘NUMC8’. “WBS Element
LS_ORDERDATA-SALES_ORDER = ‘CHAR10’. “Sales Order
LS_ORDERDATA-SALES_ORDER_ITEM = ‘NUMC6’. “Sales Order Item
LS_ORDERDATA-BUSINESS_AREA = ‘CHAR4’. “Business Area
LS_ORDERDATA-PROFIT_CENTER = ‘CHAR10’. “Profit Center
LS_ORDERDATA-SEQUENCE_NUMBER = ‘NUMC14’. “Sequence Number
LS_ORDERDATA-STOCK_TYPE = ‘CHAR1’. “Stock Type
LS_ORDERDATA-GR_PROC_TIME = ‘DEC3’. “GR processing time
LS_ORDERDATA-STORAGE_LOCATION = ‘CHAR4’. “Storage Location
LS_ORDERDATA-MRP_DISTR_KEY = ‘CHAR4’. “Distribution Key
LS_ORDERDATA-GOODS_RECIPIENT = ‘CHAR12’. “Goods Recipient
LS_ORDERDATA-UNLOADING_POINT = ‘CHAR25’. “Unloading Point
LS_ORDERDATA-MATERIAL_EXTERNAL = ‘CHAR40’. “Material Number
LS_ORDERDATA-MATERIAL_GUID = ‘CHAR32’. “GUID (External)
LS_ORDERDATA-MATERIAL_VERSION = ‘CHAR10’. “Version Number
LS_ORDERDATA-ADDITIONAL_DAYS = ‘DEC4’. “Additional Days
LS_ORDERDATA-STOCK_SEGMENT = ‘CHAR16’. “Stock Segment
LS_ORDERDATA-MATERIAL_LONG = ‘CHAR40’. “Material Number
LS_ORDERDATA-STK_SEG_LONG = ‘CHAR40’. “Stock Segment
LS_ORDERDATA-VALIDITY_OBJECT = ‘CHAR12’. “Standard Variant
LS_ORDERDATA-BASIC_SCHEDULING_TYPE = ‘CHAR1’. “Scheduling type

**********************************************************************
*******Defination of Work Area Structrue [Export]-[RETURN ] . “”Return Parameter
**********************************************************************
DATA: LS_RETURN TYPE BAPIRET2 . “”Return Parameter
DATA: LV_ORDER_NUMBER TYPE BAPI_ORDER_KEY-ORDER_NUMBER .”Obligatory
DATA: LV_ORDER_TYPE TYPE BAPI_ORDER_COPY-ORDER_TYPE .”Obligatory

**********************************************************************
*******CallUp The Function Now. .
**********************************************************************
CALL FUNCTION ‘BAPI_PRODORD_CREATE’
EXPORTING
ORDERDATA = LS_ORDERDATA
IMPORTING
RETURN = LS_RETURN
ORDER_NUMBER = LV_ORDER_NUMBER
ORDER_TYPE = LV_ORDER_TYPE
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.

About me:

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.

微信原文《The End》