Skip to Content

Short dump while updating User Status of a Project and corresponding WBS

All,

I have a requirement where the user status for project and corresponding WBS element needs to be changed more than once in one execution.

While doing so, I get a short dump - Error in individual BAPIs or precommit: posting not possible

During the first loop count, it works fine but get a shortdump for 2nd loop count. This is for ONE project.

Please help.

IF NOT lt_proj[] IS INITIAL.

* Get the Project Status

LOOP AT lt_proj INTO ls_proj.

CALL FUNCTION 'BAPI_BUS2001_GET_STATUS'

EXPORTING

project_definition = ls_proj-pspid

TABLES

e_user_status = lt_user_status.

* Only one status out of BAPI

READ TABLE lt_user_status INTO ls_user_status INDEX 1.

* Compare the user status from the BAPI with the one in Z Table

* READ TABLE lt_ztps_miles INTO ls_ztps_miles WITH KEY stsma = ls_proj-stspr.

LOOP AT lt_ztps_miles INTO ls_ztps_miles WHERE stsma = ls_proj-stspr.

* IF sy-subrc = 0.

IF ls_ztps_miles-zj_txt04 NE ls_user_status-user_status.

* Call Initialization

CALL FUNCTION 'BAPI_PS_INITIALIZATION'.

* Update the header user status via BAPI and populate the log table

CALL FUNCTION 'BAPI_BUS2001_SET_STATUS'

EXPORTING

project_definition = ls_proj-pspid

set_user_status = ls_ztps_miles-zj_txt04

TABLES

e_result = lt_result.

* Get all the lower level WBS elements for this project from table PRPS

CALL FUNCTION 'BAPI_PROJECT_GETINFO'

EXPORTING

project_definition = ls_proj-pspid

TABLES

e_wbs_element_table = lt_wbs_element_tab.

LOOP AT lt_wbs_element_tab INTO ls_wbs_element_tab.

ls_wbs_user_status-wbs_element = ls_wbs_element_tab-wbs_element.

ls_wbs_user_status-set_user_status = ls_ztps_miles-zj_txt04.

APPEND ls_wbs_user_status TO lt_wbs_user_status.

CLEAR : ls_wbs_element_tab, ls_wbs_user_status.

ENDLOOP.

CALL FUNCTION 'BAPI_BUS2054_SET_STATUS'

TABLES

i_wbs_user_status = lt_wbs_user_status.

* Populate the LOG

READ TABLE lt_result INTO ls_result WITH KEY message_type = 'E'.

IF sy-subrc = 0. "Failure

ls_log-pspnr = ls_proj-pspnr.

ls_log-before_status = ls_user_status-user_status.

ls_log-after_status = ls_user_status-user_status.

ls_log-update_status = c_failure.

APPEND ls_log TO lt_log.

ELSE."Success

ls_log-pspnr = ls_proj-pspnr.

ls_log-before_status = ls_user_status-user_status.

ls_log-after_status = ls_ztps_miles-zj_txt04.

ls_log-update_status = c_success.

APPEND ls_log TO lt_log.

ENDIF.

ENDIF.

* Call Commit Work

READ TABLE lt_log INTO ls_log WITH KEY update_status = c_success.

IF sy-subrc = 0.

* Call Pre-Committ

CALL FUNCTION 'BAPI_PS_PRECOMMIT'

TABLES

et_return = itab_return1.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

WAIT UP TO 2 SECONDS.

ENDIF.

CLEAR : ls_ztps_miles, lt_result ,lt_wbs_element_tab, lt_log.

REFRESH : lt_result ,lt_wbs_element_tab, lt_log.

* ENDIF.

ENDLOOP.

CLEAR : ls_proj, lt_user_status, ls_user_status, ls_ztps_miles, lt_result, ls_result, ls_log.

REFRESH: lt_user_status, lt_result.

ENDLOOP.

ENDIF.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Dec 05, 2013 at 06:21 AM

    Hi Salil

    After the first iteration in inner loop please add refresh for lt_wbs_user_status.. You are not refreshing user status may be more than one WBS element is going for setting the status which is not allowed

    Nabheet

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Salil,

      Did you find any solution for this. i am also facing the same issue for the first loop iteration it is setting status correctly. for the second time its going for dump in precommit statement.

      BAPI_PS_INITIALIZATION

      BAPI_BUS2054_SET_STATUS

      BAPI_PS_PRECOMMIT

      BAPI_TRANSACTION_COMMIT

      i am clearing the internal tables also correctly. I am not able to find what is going wrong.

      Thanks in Advance,

      Srivedha Sankaran

  • Posted on Nov 22, 2013 at 05:29 AM

    Hi,

    please replace the lines

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

    WAIT UP TO 2 SECONDS.

    with

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

    EXPORTING WAIT = 'X'.

    Regards,

    Klaus

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2013 at 07:34 PM

    All,

    I am still getting the same shortdump at Pre-Commit level.

    I am changing user status for an existing Project and WBS elements. Please see the following code.

    Here, I am changing multiple Projects and their corresponding WBS elements in the LOOP. After the loop, i am calling Pre-Commit once followed by Commit Work. Here i get a short dump.

    TABLES : mlst.

    CONSTANTS : c_success TYPE char7 VALUE 'SUCCESS',

    c_failure TYPE char7 VALUE 'FAILURE'.

    TYPES : BEGIN OF ty_log,

    pspnr TYPE ps_intnr,

    before_status TYPE bapi_user_status_text,

    after_status TYPE bapi_user_status_text,

    update_status TYPE char7,

    END OF ty_log.

    DATA : lt_mlst TYPE STANDARD TABLE OF mlst,

    ls_mlst TYPE mlst,

    lt_prps TYPE STANDARD TABLE OF prps,

    ls_prps TYPE prps,

    lt_proj TYPE STANDARD TABLE OF proj,

    ls_proj TYPE proj,

    lt_ztps_miles TYPE STANDARD TABLE OF ztps_miles,

    ls_ztps_miles TYPE ztps_miles,

    ls_temp TYPE ztps_miles,

    lt_log TYPE STANDARD TABLE OF ty_log,

    ls_log TYPE ty_log,

    ls_last_run TYPE ztgb_last_run_tm,

    gv_prog_name TYPE syrepid,

    prev_strt_date TYPE datum,

    prev_strt_time TYPE uzeit.

    * BAPI Tables

    DATA : lt_user_status TYPE STANDARD TABLE OF bapi_user_status,

    ls_user_status TYPE bapi_user_status,

    lt_result TYPE STANDARD TABLE OF bapi_status_result,

    ls_result TYPE bapi_status_result,

    lt_wbs_user_status TYPE STANDARD TABLE OF bapi_wbs_mnt_user_status,

    ls_wbs_user_status TYPE bapi_wbs_mnt_user_status,

    lt_wbs_element_tab TYPE STANDARD TABLE OF bapi_wbs_element_exp,

    ls_wbs_element_tab TYPE bapi_wbs_element_exp,

    itab_return1 TYPE STANDARD TABLE OF bapiret2.

    SELECT-OPTIONS : s_actdt FOR mlst-lst_actdt OBLIGATORY,

    s_pspnr FOR mlst-pspnr.

    START-OF-SELECTION.

    * Update the Z table only if executed in background.

    IF sy-batch = 'X'.

    gv_prog_name = sy-repid.

    SELECT SINGLE *

    FROM ztgb_last_run_tm

    INTO ls_last_run

    WHERE z_pgm_id = gv_prog_name

    AND z_proc_num = 1.

    IF sy-subrc <> 0.

    ls_last_run-z_pgm_id = gv_prog_name.

    ls_last_run-z_proc_num = 1.

    ls_last_run-z_last_run_date = sy-datum.

    ls_last_run-z_last_run_time = sy-uzeit.

    INSERT INTO ztgb_last_run_tm VALUES ls_last_run.

    ELSE.

    prev_strt_date = ls_last_run-z_last_run_date.

    prev_strt_time = ls_last_run-z_last_run_time.

    ls_last_run-z_last_run_date = sy-datum.

    ls_last_run-z_last_run_time = sy-uzeit.

    MODIFY ztgb_last_run_tm

    FROM ls_last_run.

    ENDIF.

    ENDIF.

    * Get data from MLST

    SELECT * FROM mlst

    INTO TABLE lt_mlst

    WHERE pspnr IN s_pspnr AND

    lst_actdt IN s_actdt.

    IF sy-subrc = 0.

    * Get Project information

    SELECT * FROM prps

    INTO TABLE lt_prps

    FOR ALL ENTRIES IN lt_mlst

    WHERE pspnr = lt_mlst-pspnr AND

    stufe = '1'.

    IF sy-subrc = 0.

    SELECT * FROM proj

    INTO TABLE lt_proj

    FOR ALL ENTRIES IN lt_prps

    WHERE pspnr = lt_prps-psphi.

    ENDIF.

    SELECT * FROM ztps_miles

    INTO TABLE lt_ztps_miles

    FOR ALL ENTRIES IN lt_mlst

    WHERE begru EQ lt_mlst-begru AND

    zj_txt04 NE space.

    ENDIF.

    IF NOT lt_proj[] IS INITIAL.

    * Get the Project Status

    LOOP AT lt_proj INTO ls_proj.

    * Call Initialization

    CALL FUNCTION 'BAPI_PS_INITIALIZATION'.

    CALL FUNCTION 'BAPI_BUS2001_GET_STATUS'

    EXPORTING

    project_definition = ls_proj-pspid

    TABLES

    e_user_status = lt_user_status.

    * Only one status out of BAPI

    READ TABLE lt_user_status INTO ls_user_status INDEX 1.

    * Compare the user status from the BAPI with the one in Z Table

    LOOP AT lt_ztps_miles INTO ls_ztps_miles WHERE stsma = ls_proj-stspr.

    * Get the sequence number for the user status at the Project level

    CLEAR ls_temp.

    READ TABLE lt_ztps_miles INTO ls_temp WITH KEY stsma = ls_proj-stspr

    zj_txt04 = ls_user_status-user_status.

    IF ls_ztps_miles-zj_txt04 NE ls_user_status-user_status AND

    ls_ztps_miles-seq GT ls_temp-seq.

    * Update the header user status via BAPI and populate the log table

    CALL FUNCTION 'BAPI_BUS2001_SET_STATUS'

    EXPORTING

    project_definition = ls_proj-pspid

    set_user_status = ls_ztps_miles-zj_txt04

    TABLES

    e_result = lt_result.

    * Get all the lower level WBS elements for this project from table PRPS

    CALL FUNCTION 'BAPI_PROJECT_GETINFO'

    EXPORTING

    project_definition = ls_proj-pspid

    TABLES

    e_wbs_element_table = lt_wbs_element_tab.

    LOOP AT lt_wbs_element_tab INTO ls_wbs_element_tab.

    ls_wbs_user_status-wbs_element = ls_wbs_element_tab-wbs_element.

    ls_wbs_user_status-set_user_status = ls_ztps_miles-zj_txt04.

    APPEND ls_wbs_user_status TO lt_wbs_user_status.

    CLEAR : ls_wbs_element_tab, ls_wbs_user_status.

    ENDLOOP.

    CALL FUNCTION 'BAPI_BUS2054_SET_STATUS'

    TABLES

    i_wbs_user_status = lt_wbs_user_status.

    * Populate the LOG

    READ TABLE lt_result INTO ls_result WITH KEY message_type = 'E'.

    IF sy-subrc = 0. "Failure

    ls_log-pspnr = ls_proj-pspnr.

    ls_log-before_status = ls_user_status-user_status.

    ls_log-after_status = ls_user_status-user_status.

    ls_log-update_status = c_failure.

    APPEND ls_log TO lt_log.

    ELSE."Success

    ls_log-pspnr = ls_proj-pspnr.

    ls_log-before_status = ls_user_status-user_status.

    ls_log-after_status = ls_ztps_miles-zj_txt04.

    ls_log-update_status = c_success.

    APPEND ls_log TO lt_log.

    ENDIF.

    ENDIF.

    CLEAR : ls_ztps_miles, lt_result ,lt_wbs_element_tab.

    REFRESH : lt_result ,lt_wbs_element_tab.

    ENDLOOP.

    CLEAR : ls_proj, lt_user_status, ls_user_status, ls_ztps_miles, lt_result, ls_result, ls_log.

    REFRESH: lt_user_status, lt_result.

    ENDLOOP.

    ENDIF.

    * Call Commit Work

    READ TABLE lt_log INTO ls_log WITH KEY update_status = c_success.

    IF sy-subrc = 0.

    CLEAR : itab_return1[].

    * Call Pre-Committ

    CALL FUNCTION 'BAPI_PS_PRECOMMIT'

    TABLES

    et_return = itab_return1.

    COMMIT WORK AND WAIT.

    CLEAR : ls_ztps_miles, lt_result ,lt_wbs_element_tab.

    REFRESH : lt_result ,lt_wbs_element_tab.

    ENDIF.

    END-OF-SELECTION.

    IF NOT lt_log[] IS INITIAL.

    * Display the results.

    WRITE : /1'Project Definition', 30 'Before User Status', 50 'After User Status', 75 'Update Status'.

    NEW-LINE.

    ULINE AT 1(90).

    LOOP AT lt_log INTO ls_log.

    WRITE:/1 ls_log-pspnr,

    30 ls_log-before_status,

    50 ls_log-after_status,

    75 ls_log-update_status.

    ENDLOOP.

    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.