on 2016 May 19 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
Request clarification before answering.
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 |
|---|---|
| 12 | |
| 10 | |
| 8 | |
| 2 | |
| 2 | |
| 2 | |
| 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.