cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI to read and change schedule lines in APO

Former Member
0 Kudos

Hello experts,

We want to firm schedule lines inside the firm zone of the APO procurement scheduling agreements with a daily job. For this we are trying to use BAPI BAPI_POSRVAPS_GETLIST3 and BAPI_POSRVAPS_SAVEMULTI3. The getlist one does not return schedule lines, it returns purchase orders and purchase requisitions. Are these the right bapis to read and change schedule lines in APO? or is there anyother one we can use?

Thanks and regards,

Ergul

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can use the below code to read the schedule lines.

  • Checking a session exists

CALL FUNCTION '/SAPAPO/RRP_SIMSESSION_GET'

IMPORTING

ev_simsession = gv_sims

es_gen_params = gv_params.

  • If not create a new session and read it

IF gv_sims IS INITIAL.

CALL FUNCTION '/SAPAPO/RRP_SIMSESSION_CREATE'

IMPORTING

ev_simsession = gv_sims.

CALL FUNCTION '/SAPAPO/RRP_SIMSESSION_GET'

IMPORTING

ev_simsession = gv_sims

es_gen_params = gv_params.

g_cre_chk = 'X'.

ENDIF.

CALL FUNCTION '/SAPAPO/CMDS_TPSRC_GET'

EXPORTING

iv_ebeln = p_l_t_acknh_ebeln

iv_ebelp = p_l_t_acknh_ebelp

TABLES

et_tpsrc_all = lt_tpsrc

EXCEPTIONS

matid_not_found = 1

locfrom_not_found = 2

locto_not_found = 3

scheduling_agreement_not_found = 4

error_selecting_schedagreement = 5

OTHERS = 6.

IF sy-subrc = 0.

  • reading the scheduling agreement records

READ TABLE lt_tpsrc INTO ls_tpsrc INDEX 1.

CALL FUNCTION '/SAPAPO/PWB_BZQID_GET_ORDER'

EXPORTING

iv_simid = '000'

iv_bzqid = ls_tpsrc-bzqid

IMPORTING

ev_ordid = lv_iordid

EXCEPTIONS

lc_connect_failed = 1

no_elements = 2

unit_conversion_failed = 3

OTHERS = 4.

IF sy-subrc = 0.

CALL FUNCTION '/SAPAPO/PWB_GET_RELATED_ORDERS'

EXPORTING

iv_ordid = lv_iordid

iv_order_type = '16'

iv_simid = '000'

IMPORTING

ev_ordid = lv_eordid

EXCEPTIONS

order_not_found = 1

lc_connect_failed = 2

no_elements = 3

OTHERS = 4.

IF sy-subrc = 0.

APPEND lv_eordid TO lt_ordid.

CALL FUNCTION '/SAPAPO/DM_PO_READ'

EXPORTING

iv_simsession = gv_sims

is_gen_params = gv_params

it_ordid = lt_ordid

IMPORTING

et_schedule = p_lt_sched

EXCEPTIONS

lc_connect_failed = 1

lc_com_error = 2

lc_appl_error = 3

OTHERS = 4.

ENDIF.

ENDIF.

ENDIF.

Use '/SAPAPO/CMDS_SNP_MM_ORD_MODIFY' function module to change the schedule lines (Pass '16' to iv_order_type parameter).

Let me know if u have any issues.

Regards,

Siva.

Answers (0)