TCODE MD61 SAMPLE DEMO BAPI_REQUIREMENTS_CREATE

Today we will learn how to use TCODE MD61 SAMPLE DEMO BAPI_REQUIREMENTS_CREATE:Planned Independent Requirements: Create Planned Independent Reqmts

*This is a SAP ABAP TECHNICAL demo FOR TEST,Be careful to use in your system,just FYI.EPlanned Independent Requirements: Create Planned Independent Reqmts
*If you have any solution,Please feel free to talk with your IT team/SAP ABAP professional guys. Planned Independent Requirements: Create Planned Independent Reqmts
*This method can be used to create <ZH>planned independent requirements
*.
*To do this, you must transfer at least the item data and the schedule
*line data. For configurable materials, you can also define configuration
*supporting points for the schedule lines.
*The <ZH>item data is transferred back after the successful creation
*of a planned independent requirement.
*Any errors that occur are returned in the parameter <ZK>RETURN.
*
*The authorization object <DS:UO.C_PPBD>C_PPBD with the
*activity <LS>H (add) is checked.
*The command <AB>COMMIT WORK is entered within the BAPI. You can
*prevent this by setting the parameter <ZK>DO_COMMIT with initial
*value.
*In this case, you call up method
*<DS:FU.BAPI_TRANSACTION_COMMIT>BapiService.TransactionCommit
*to write the planned independent requirements to the database.
*
*If you have created a planning profile for a configurable material,
*you can define <ZH>configuration supporting points for the
*schedule lines as follows:
*Select a planning profile using parameter<ZK>PROFILID.
*Define the usage probabilities using
*parameter <ZK>REQUIREMENTS_CHAR_IN.
*The requirements date of the configuration supporting point (
*<ZK>REQUIREMENTS_CHAR_IN-REQU_DATE) must correspond to the
*requirements date of the schedule line
*<ZK>(REQUIREMENTS_SCHEDULE_IN-REQ_DATE).
*Do not create any schedule lines on non-working days,
*as these will be automatically moved to a workday.
*Additional methods:
*<DS:FU.BAPI_REQUIREMENTS_CHANGE>PlannedIndepReqmt.Change
*<DS:FU.BAPI_REQUIREMENTS_GETDETAIL>PlannedIndepReqmt.GetDetail
*<DS:FU.BAPI_TRANSACTION_COMMIT>BapiService.TransactionCommit
*

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

**********************************************************************
*******Defination of Work Area Structrue [Import]-[REQUIREMENTS_ITEM ] . “”Communication fields: indep. reqmts item data table
**********************************************************************
DATA: LS_REQUIREMENTS_ITEM TYPE BAPISITEMR . “”Communication fields: indep. reqmts item data table
LS_REQUIREMENTS_ITEM-MATERIAL = ‘CHAR18’. “Material
LS_REQUIREMENTS_ITEM-PLANT = ‘CHAR4’. “Plant
LS_REQUIREMENTS_ITEM-REQU_TYPE = ‘CHAR4’. “Requirements type
LS_REQUIREMENTS_ITEM-VERSION = ‘CHAR2’. “Version
LS_REQUIREMENTS_ITEM-VERS_ACTIV = ‘CHAR1’. “Active
LS_REQUIREMENTS_ITEM-REQ_NUMBER = ‘CHAR10’. “Requirements Plan
LS_REQUIREMENTS_ITEM-MATERIAL_EXTERNAL = ‘CHAR40’. “Material Number
LS_REQUIREMENTS_ITEM-MATERIAL_GUID = ‘CHAR32’. “GUID (External)
LS_REQUIREMENTS_ITEM-MATERIAL_VERSION = ‘CHAR10’. “Version Number
LS_REQUIREMENTS_ITEM-MRP_AREA = ‘CHAR10’. “MRP Area
LS_REQUIREMENTS_ITEM-REQ_PLAN_ID_EXT = ‘CHAR10’. “Ext. Req. Plan
LS_REQUIREMENTS_ITEM-REQ_SEGMENT = ‘CHAR16’. “Requirement Segment
LS_REQUIREMENTS_ITEM-MATERIAL_LONG = ‘CHAR40’. “Material
LS_REQUIREMENTS_ITEM-REQ_SEG_LONG = ‘CHAR40’. “Requirement Segment

**********************************************************************
*******Defination of Work Area Structrue [Import]-[REQUIREMENT_PARAM ] . “”Common work area for planned indep. requirements functions
**********************************************************************
DATA: LS_REQUIREMENT_PARAM TYPE CM60R . “”Common work area for planned indep. requirements functions
LS_REQUIREMENT_PARAM-TRTYP = ‘CHAR1’. “Transaction type
LS_REQUIREMENT_PARAM-CONFL = ‘CHAR1’. ”
LS_REQUIREMENT_PARAM-COMMI = ‘CHAR1’. ”
LS_REQUIREMENT_PARAM-UPDDC = ‘CHAR1’. ”
LS_REQUIREMENT_PARAM-DELKZ = ‘CHAR1’. “Deletion Indicator
LS_REQUIREMENT_PARAM-BEDAB = ‘CHAR1’. “Derive reqmts type
LS_REQUIREMENT_PARAM-LANGU = ‘LANG1’. “Language Key of Text Environment
LS_REQUIREMENT_PARAM-SYNCRON = ‘CHAR1’. ”
LS_REQUIREMENT_PARAM-STATUS = ‘CHAR1’. ”
LS_REQUIREMENT_PARAM-INNUM = ‘CHAR1’. ”
LS_REQUIREMENT_PARAM-APROG = ‘CHAR1’. “Reference
LS_REQUIREMENT_PARAM-NOENTMG = ‘CHAR1’. ”
LS_REQUIREMENT_PARAM-MDVM_BUFFER = ‘CHAR1’. ”
LS_REQUIREMENT_PARAM-ADDUP = ‘CHAR1′. ”
DATA: LV_DO_COMMIT TYPE BAPISPARAM-DO_COMMIT .”Option,Default Value =’X’,
DATA: LV_UPDATE_MODE TYPE BAPISPARAM-UPDATE_MODE .”Option,Default Value =’X’,
DATA: LV_REFER_TYPE TYPE BAPISPARAM-REFER_TYPE .”Option,Default Value =SPACE,
DATA: LV_PROFILID TYPE BAPISPARAM-PROFILID .”Option,Default Value =SPACE,
DATA: LV_MATERIAL TYPE BAPISITEMR-MATERIAL .”Obligatory
DATA: LV_PLANT TYPE BAPISITEMR-PLANT .”Obligatory
DATA: LV_REQUIREMENTSTYPE TYPE BAPISITEMR-REQU_TYPE .”Obligatory
DATA: LV_VERSION TYPE BAPISITEMR-VERSION .”Obligatory
DATA: LV_REQMTSPLANNUMBER TYPE BAPISITEMR-REQ_NUMBER .”Obligatory
DATA: LV_MRP_AREA TYPE BAPISITEMR-MRP_AREA .”Obligatory

**********************************************************************
*******Defination of Work Area Structrue [Export]-[MATERIAL_EVG ] . “”Bapie Structure for transfer of external material no, ver.,
**********************************************************************
DATA: LS_MATERIAL_EVG TYPE BAPIMGVMATNR . “”Bapie Structure for transfer of external material no, ver.,
DATA: LV_REQ_PLAN_ID_EXT TYPE BAPISITEMR-REQ_PLAN_ID_EXT .”Obligatory
DATA: LV_REQ_SEGMENT TYPE BAPISITEMR-REQ_SEGMENT .”Obligatory
DATA: LV_MATERIAL_LONG TYPE BAPISITEMR-MATERIAL_LONG .”Obligatory
DATA: LV_REQ_SEG_LONG TYPE BAPISITEMR-REQ_SEG_LONG .”Obligatory

**********************************************************************
*******Defination of [Tables]-[REQUIREMENTS_SCHEDULE_IN] .
**********************************************************************
DATA: LT_REQUIREMENTS_SCHEDULE_IN TYPE STANDARD TABLE OF BAPISSHDIN.””Communication fields: indep. reqmts schedule lines input
DATA: LS_REQUIREMENTS_SCHEDULE_IN TYPE BAPISSHDIN .””Communication fields: indep. reqmts schedule lines input
LS_REQUIREMENTS_SCHEDULE_IN-DATE_TYPE = ‘CHAR1’. “Date type
LS_REQUIREMENTS_SCHEDULE_IN-REQ_DATE = ‘20241210’. “Delivery Date
LS_REQUIREMENTS_SCHEDULE_IN-REQ_QTY = ‘QUAN13’. “Planned quantity
LS_REQUIREMENTS_SCHEDULE_IN-UNIT = ‘UNIT3’. “Base Unit of Measure
LS_REQUIREMENTS_SCHEDULE_IN-BOMEXPL = ‘CHAR8’. “BOM explosion number
LS_REQUIREMENTS_SCHEDULE_IN-PROD_VES = ‘CHAR4’. “Production Version
APPEND LS_REQUIREMENTS_SCHEDULE_IN TO LT_REQUIREMENTS_SCHEDULE_IN .
CLEAR LS_REQUIREMENTS_SCHEDULE_IN .

**********************************************************************
*******Defination of [Tables]-[REQUIREMENTS_CHAR_IN] .
**********************************************************************
DATA: LT_REQUIREMENTS_CHAR_IN TYPE STANDARD TABLE OF BAPISCHARR.””Communication fields: indep. reqmts characteristic values
DATA: LS_REQUIREMENTS_CHAR_IN TYPE BAPISCHARR .””Communication fields: indep. reqmts characteristic values
LS_REQUIREMENTS_CHAR_IN-REQU_DATE = ‘20241210’. “Delivery Date
LS_REQUIREMENTS_CHAR_IN-INT_CHAR = ‘NUMC10’. “Internal char no.
LS_REQUIREMENTS_CHAR_IN-CHAR_VALUE = ‘CHAR30’. “Characteristic Value
LS_REQUIREMENTS_CHAR_IN-CH_QTY = ‘FLTP16’. “Quantity
LS_REQUIREMENTS_CHAR_IN-FIXING = ‘CHAR1’. “Fixing indicator
LS_REQUIREMENTS_CHAR_IN-COPY_FRMED = ‘CHAR1’. “Copy firmed objcts allowed
LS_REQUIREMENTS_CHAR_IN-FLAG_USAGE = ‘CHAR1’. “Usage probability flag
LS_REQUIREMENTS_CHAR_IN-PT_NUMBER = ‘NUMC10’. “Internal class no.
LS_REQUIREMENTS_CHAR_IN-PT_LINE = ‘NUMC5’. “Row Number
LS_REQUIREMENTS_CHAR_IN-CHAR_VALUE_LONG = ‘CHAR70’. “Characteristic Value
APPEND LS_REQUIREMENTS_CHAR_IN TO LT_REQUIREMENTS_CHAR_IN .
CLEAR LS_REQUIREMENTS_CHAR_IN .

**********************************************************************
*******Defination of [Tables]-[RETURN] .
**********************************************************************
DATA: LT_RETURN TYPE STANDARD TABLE OF BAPIRETURN1.””Return Parameter
DATA: LS_RETURN TYPE BAPIRETURN1 .””Return Parameter
LS_RETURN-TYPE = ‘CHAR1’. “Message type
LS_RETURN-ID = ‘CHAR20’. “Message Class
LS_RETURN-NUMBER = ‘NUMC3’. “Message Number
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_REQUIREMENTS_CREATE’
EXPORTING
REQUIREMENTS_ITEM = LS_REQUIREMENTS_ITEM
* REQUIREMENT_PARAM = LS_REQUIREMENT_PARAM
* DO_COMMIT = ‘X’
* UPDATE_MODE = ‘X’
* REFER_TYPE = ”
* PROFILID = ”
IMPORTING
MATERIAL = LV_MATERIAL
PLANT = LV_PLANT
REQUIREMENTSTYPE = LV_REQUIREMENTSTYPE
VERSION = LV_VERSION
REQMTSPLANNUMBER = LV_REQMTSPLANNUMBER
MRP_AREA = LV_MRP_AREA
MATERIAL_EVG = LS_MATERIAL_EVG
REQ_PLAN_ID_EXT = LV_REQ_PLAN_ID_EXT
REQ_SEGMENT = LV_REQ_SEGMENT
MATERIAL_LONG = LV_MATERIAL_LONG
REQ_SEG_LONG = LV_REQ_SEG_LONG
TABLES
REQUIREMENTS_SCHEDULE_IN = LT_REQUIREMENTS_SCHEDULE_IN
* REQUIREMENTS_CHAR_IN = LT_REQUIREMENTS_CHAR_IN
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.

 

BAPI_TRADINGCONTRACT_CREATE sample example

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》

今日热点在看SAP HOT583