on 05-19-2016 5:56 AM
Hello experts,
I have a requirement to delete old schedule lines and create new schedule lines through file. I was working on FM /SAPAPO/DM_PO_CHANGE.
The schedule lines get deleted through the FM when passing the parameter 'Method' = 'D' "D for delete.
But when I map the file parameters to the it_schedule parameter of FM /SAPAPO/DM_PO_CHANGE with 'method' parameter = 'A' (A for Add) to create new schedule lines, I get 'LC_APP_ERROR' (sy-subrc = 3). I am unable to understand what parameters are necessary to be filled in it_schedule internal table to create new schedule lines.
Currently my code looks like below -
<Code>
LOOP AT lt_file INTO ls_file.
ls_schedule -method = 'A'. "A for add
ls_schedule-orderid = ls_file-orderid. " This gets populated by converting ebeln(scheduling agreement number) to orderid
ls_schedule-itemno = ls_file-itemno.
ls_schedule-schedno = ls_file-schedno.
CALL FUNCTION '/SAPAPO/DATE_CONVERT_TIMESTAMP'
EXPORTING
iv_date = ls_file-avl_date
iv_time = sy-uzeit
IMPORTING
ev_timestamp = ls_schedule-avail_time.
CALL FUNCTION '/SAPAPO/DATE_CONVERT_TIMESTAMP'
EXPORTING
iv_date = ls_file-ship_date
iv_time = sy-uzeit
IMPORTING
ev_timestamp = ls_schedule-gi_end_time.
ls_schedule-to_org_quantity = ls_file-sch_qty.
ls_schedule-to_ext_fixed = ls_file-fixed.
APPEND ls_schedule TO lt_schedule.
ENDLOOP.
ls_gen_aprm-simversion = '000'.
CALL FUNCTION '/SAPAPO/DM_PO_CHANGE'
EXPORTING
is_gen_params = ls_gen_parm
it_schedule = lt_schedule
IMPORTING
et_rc = lt_rc
et_sched_failures = lt_schd_fail
EXCEPTIONS
lc_connect_failed = 1
lc_com_error = 2
lc_appl_error = 3
OTHERS = 4.
</Code>
I am getting sy-subrc = '3'.
One thing I would like to add here is that
I am using following approach -
/SAPAPO/CMDS_TPSRC_GET - To get BZQID by passing EBELN from file.
/SAPAPO/PWB_BZQID_GET_ORDER - To get ORDERID in structure ES_ORDKEY By passing BZQID received from previous FM & IV_ORDER_TYPE = '16'.
If I pass iv_order_type as '16' (for scheduling agreement) then I get schedule line detials in FM /SAPPO/DM_PO_READ but if I pass iv_order_type as '17' (release plan) then I get release schedule in FM /SAPAPO/DM_PO_READ. ORDERID for type '16' is different than ORDERID for type '17'.
Once I delete schedule lines for order type '16', then I don't get order number for type '16' instead I get only details for order type '17'.
If this is the reason I am unable to add new schedule lines, could anyone please suggest a better approach? How to delete old schedule lines and create new schedule lines using FMs/Class methods?
Regards
Yayati Ekbote
Hello experts,
I have found a way to create schedule lines.
<Code>
LOOP AT lt_file INTO ls_file.
CALL FUNCTION '/SAPAPO/RRP_SOURCES_GET'
EXPORTING
iv_pegid = lv_pegid "found previously using product & location
iv_quantity = ls_file-sch_qty
iv_reqdat = ls_file-reqdat
iv_dialog = abap_false
iv_buffer_flg = abap_true
iv_order_create = abap_true
IMPORTING
et_source = lt_source
et_sources_valid = lt_src_vld
EXCEPTIONS
user_canceled = 1
not_qualified = 2
unknown_error = 3
OTHERS = 4.
READ TABLE lt_src_vld INTO DATA(ls_src_vld) WITH KEY ebeln = ls_file-ebeln
ebelp = ls_file-itmno.
IF sy-subrc IS INITIAL AND
ls_src_vld IS NOT INITIAL.
READ TABLE lt_source INTO DATA(ls_src) WITH KEY trpid = ls_src_vld-trpid.
IF sy-subrc IS INITIAL AND
ls_src IS NOT INITIAL.
CALL FUNCTION '/SAPAPO/RRP_ORDER_CREATE'
EXPORTING
iv_pegid = lv_pegid
iv_quantity = ls_file-sch_qty
iv_scrap = 0
iv_rqmtti = lv_reqtti "date converted to time stamp
iv_startti = lv_strtti "date converted to time stamp
iv_firmed = abap_true
iv_priority = 0
is_source = ls_src
iv_application = lv_app
iv_dialog = abap_false
IMPORTING
ev_ordid = ls_srec-ordid
ev_schedid = ls_srec-schedid
ev_ordno = ls_srec-ordno
ev_position_no = ls_srec-posno
ev_line_no = ls_srec-linno
ev_subrc = ls_srec-subrc
ev_actid = ls_srec-actid
ev_io_time = ls_srec-iotim
ev_ippe_id = ls_srec-ippeid
ev_no_inputs = ls_srec-ipno
APPEND ls_rec TO lt_rec.
CLEAR ls_rec .
ENDLOOP.
LOOP AT lt_rec INTO ls_rec WHERE subrc NE 0.
lv_fail = abap_true.
ENDLOOP.
IF lv_fail EQ abap_false.
COMMIT WORK.
ENDIF.
</Code>
But even if I do commit work, the newly created schedule lines are not saved to system.
Kindly let me know what I am missing.
I am having a doubt that some how global buffer tables are not getting filled.
If this is the case, can anyone let me know how to do it?
Regards,
Yayati Ekbote
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear sir,good evening. I want to delete certain records out of a record set. I tried by referring to your demo,however I deleted all the records in the set rather than some of them. I am confused cause I couldn't find out the reason. Could you help me to have a look at my code where is the problem please?
the code is attached bellow:
create object zob_dao_ds.
LS_PARAM-PARAM = 'USE_SIMSESSION'.
LS_PARAM-VALUE = '-'.
APPEND LS_PARAM TO LT_PARAM.
CLEAR LS_PARAM.
LS_PARAM-PARAM = 'VERSION_ID'.
LS_PARAM-VALUE = '000'.
APPEND LS_PARAM TO LT_PARAM.
CLEAR LS_PARAM.
try.
CALL METHOD ZOB_DAO_DS->/scmb/if_tdl_dao_general~init
EXPORTING
it_init_paramtab = LT_PARAM.
.
catch /scmb/cx_tdl_dao .
endtry.
clear lv_msg.
TRY.
CALL METHOD ZOB_DAO_DS->/SCMB/IF_TDL_DELIVERYSCHEDULE~GET
EXPORTING
IV_VRSIOID = '000'
IT_ORDID = LT_ORDID
IT_MATIDLOCID = LT_MATID
* IT_SELPARAMS =
* IV_BUFFER_CTRL = /SCMB/CL_TDL_CONST=>GC_DB_AND_BUFFER
* IV_LOCKFLAG = ABAP_FALSE
IMPORTING
ET_ORDER = lt_order
CHANGING
CV_MSGTY = lv_msg
CT_RETURN = lt_return.
CATCH /SCMB/CX_TDL_DAO .
ENDTRY.
DATA LV_ITEMNO TYPE /SCMB/TDL_DELPS.
DATA LV_NO TYPE /SCMB/TDL_RLINE.
DATA LS_NO TYPE /SCMB/TDL_RLINE.
DATA LT_NO TYPE STANDARD TABLE OF /SCMB/TDL_RLINE.
* data ls_item type /SCMB/TDL_DS_SDL_STR.
CLEAR LV_TABIX.
IF LT_ORDER[] IS NOT INITIAL.
LOOP AT LT_ORDER INTO US_ORDER.
LS_ORDER-ORDNO = US_ORDER-ORDNO.
LS_ORDER-ITEMNO = US_ORDER-ITEMNO.
LS_ORDER-VRSIOID = US_ORDER-VRSIOID .
LS_ORDER-ORDID = US_ORDER-ORDID .
LS_ORDER-LOCIDFROM = US_ORDER-LOCIDFROM.
LS_ORDER-BZQID = US_ORDER-BZQID.
LS_ORDER-TRPID = US_ORDER-TRPID.
LS_ORDER-LOCIDTO = US_ORDER-LOCIDTO.
LS_ORDER-MATID = US_ORDER-MATID.
LS_ORDER-APPRVL_STATE = US_ORDER-APPRVL_STATE.
LS_ORDER-NOTE_EXISTS = US_ORDER-NOTE_EXISTS.
CLEAR LV_ITEMNO.
LV_ITEMNO = US_ORDER-ITEMNO.
LOOP AT GT_IO WHERE ORDNO = US_ORDER-ORDNO AND
POSITION_NO = LV_ITEMNO.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = GT_IO-LINE_NO
IMPORTING
OUTPUT = GT_IO-LINE_NO
.
CLEAR LV_NO.
LV_NO = GT_IO-LINE_NO.
READ TABLE US_ORDER-ITEM ASSIGNING <LS_ITEM> WITH KEY SCHEDNO = LV_NO.
IF SY-SUBRC = 0.
LS_ITEM-SDLID = <LS_ITEM>-SDLID.
LS_ITEM-BUYTYPE_CODE = <LS_ITEM>-BUYTYPE_CODE.
LS_ITEM-SUPPLIER_BUYTYPE_CODE = <LS_ITEM>-SUPPLIER_BUYTYPE_CODE.
LS_ITEM-ORIGQTY = <LS_ITEM>-ORIGQTY.
LS_ITEM-RECQTY = <LS_ITEM>-RECQTY.
LS_ITEM-OPENQTY = <LS_ITEM>-OPENQTY.
LS_ITEM-OPENQTY = <LS_ITEM>-OPENQTY.
LS_ITEM-AVAIL_TIME = <LS_ITEM>-AVAIL_TIME.
LS_ITEM-GR_TIME = <LS_ITEM>-GR_TIME.
LS_ITEM-GI_TIME = <LS_ITEM>-GI_TIME.
LS_ITEM-TTYPE = <LS_ITEM>-TTYPE.
LS_ITEM-FIXED = <LS_ITEM>-FIXED.
LS_ITEM-FROM_CAT = <LS_ITEM>-FROM_CAT.
LS_ITEM-TO_CAT = <LS_ITEM>-TO_CAT.
LS_ITEM-SCHEDNO = LV_NO.
APPEND LS_ITEM TO LS_ORDER-ITEM.
ELSE.
CONTINUE.
ENDIF.
CLEAR LS_ITEM.
CLEAR GT_IO.
ENDLOOP.
APPEND LS_ORDER TO UT_ORDER.
CLEAR LS_ORDER.
CLEAR US_ORDER.
ENDLOOP.
ENDIF.
if Ut_order is not INITIAL.
TRY.
CALL METHOD ZOB_DAO_DS->/SCMB/IF_TDL_DELIVERYSCHEDULE~SET
EXPORTING
IV_VRSIOID = '000'
IT_ORDER = Ut_order
CHANGING
* CV_MSGTY =
CT_RETURN = ut_return.
.
CATCH /SCMB/CX_TDL_DAO .
ENDTRY.
ENDIF.
TRY.
CALL METHOD ZOB_DAO_DS->/SCMB/IF_TDL_DELIVERYSCHEDULE~DELETE
EXPORTING
IV_VRSIOID = '000'
IT_ORDID = lt_ORDID
CHANGING
* CV_MSGTY =
CT_RETURN = UT_RETURN.
CATCH /SCMB/CX_TDL_DAO .
ENDTRY.
TRY.
CALL METHOD ZOB_DAO_DS->/SCMB/IF_TDL_DAO_GENERAL~SAVE_TO_DB
CHANGING
* CV_MSGTY =
CT_RETURN = LT_RETTAB.
.
CATCH /SCMB/CX_TDL_DAO .
ROLLBACK WORK.
ENDTRY.
TRY.
CALL METHOD ZOB_DAO_DS->/SCMB/IF_TDL_DAO_GENERAL~FREE
.
CATCH /SCMB/CX_TDL_DAO .
ROLLBACK WORK.
ENDTRY.
Your kindly help would be highly appreciated. Looking forward to hearing from you soon.
best regards!
Emily.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
4 | |
3 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.