Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI shortdump

Former Member
0 Kudos

Hi,

please help me in creating project definiton with out short dump.

Iam writing my code here.

DATA : gv_bsart like ekko-bsart,

gv_lifnr like ekko-lifnr,

gv_objnr like proj-objnr.

DATA : gs_proj like proj.

FORM build_studio_proj_fields.

gv_objnr = 'PD00000093'.

SELECT SINGLE * FROM PROJ INTO gs_proj

WHERE objnR = gv_objnr.

IF sy-subrc <> 0.

WRITE:/ 'There is some error'.

ENDIF.

CLEAR: gs_proj-pspnr, gs_proj-objnr.

gs_proj-pspid = 'IMN.IMN-BRA.05038'.

gs_proj-post1 = 'Pal Test project IMN.IMN-BRA.05038'.

gs_proj-ernam = 'XARMUGP'.

gs_proj-erdat = '20051121'.

gs_proj-plsez = '20051121'.

gs_proj-postu = 'PROJECT DEFINITION IMN.IMN-BRA.05038'.

ENDFORM. " build_studio_proj_fields

CALL FUNCTION '2001_PROJECTDEF_CREATE'

EXPORTING

PROJECT_DEFINITION_STRU = gs_proj

IMPORTING

RETURN = gs_BAPIRETURN1

TABLES

E_MESSAGE_TABLE = gs_BAPI_METH_MESSAGE

.

When iam execting this program, iam getting short dump.

How can i solve this.

THanks,

Veeru

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Your gs_proj structure should be of type BAPI_PROJECT_DEFINITION and not PROJ.

DATA : gv_bsart like ekko-bsart,

gv_lifnr like ekko-lifnr,

gv_objnr like proj-objnr.

<b>DATA : gs_proj like BAPI_PROJECT_DEFINITION.</b>

FORM build_studio_proj_fields.

gv_objnr = 'PD00000093'.

SELECT SINGLE * FROM PROJ INTO gs_proj

WHERE objnR = gv_objnr.

IF sy-subrc <> 0.

WRITE:/ 'There is some error'.

ENDIF.

CLEAR: gs_proj-pspnr, gs_proj-objnr.

gs_proj-pspid = 'IMN.IMN-BRA.05038'.

gs_proj-post1 = 'Pal Test project IMN.IMN-BRA.05038'.

gs_proj-ernam = 'XARMUGP'.

gs_proj-erdat = '20051121'.

gs_proj-plsez = '20051121'.

gs_proj-postu = 'PROJECT DEFINITION IMN.IMN-BRA.05038'.

ENDFORM. " build_studio_proj_fields

CALL FUNCTION '2001_PROJECTDEF_CREATE'

EXPORTING

PROJECT_DEFINITION_STRU = gs_proj

IMPORTING

RETURN = gs_BAPIRETURN1

TABLES

E_MESSAGE_TABLE = gs_BAPI_METH_MESSAGE

.

<b>Also revise your build_studio_proj_fields routine logic accordingly.</b>

Sri

Message was edited by: Srikanth Pinnamaneni

10 REPLIES 10

former_member181962
Active Contributor
0 Kudos

Hi Veeru,

What message are you getting in the short dump?

Regards,

Ravi

0 Kudos

hi ravi,

The call to the function module "2001_PROJECTDEF_CREATE" is incorrect:

In the function module interface, you can specify only

fields of a specific type and length under "PROJECT_DEFINITION_STRU".

Although the currently specified field

"GS_PROJ" is the correct type, its length is incorrect.

Thanks,

Veeru

Former Member
0 Kudos

Hi,

Your gs_proj structure should be of type BAPI_PROJECT_DEFINITION and not PROJ.

DATA : gv_bsart like ekko-bsart,

gv_lifnr like ekko-lifnr,

gv_objnr like proj-objnr.

<b>DATA : gs_proj like BAPI_PROJECT_DEFINITION.</b>

FORM build_studio_proj_fields.

gv_objnr = 'PD00000093'.

SELECT SINGLE * FROM PROJ INTO gs_proj

WHERE objnR = gv_objnr.

IF sy-subrc <> 0.

WRITE:/ 'There is some error'.

ENDIF.

CLEAR: gs_proj-pspnr, gs_proj-objnr.

gs_proj-pspid = 'IMN.IMN-BRA.05038'.

gs_proj-post1 = 'Pal Test project IMN.IMN-BRA.05038'.

gs_proj-ernam = 'XARMUGP'.

gs_proj-erdat = '20051121'.

gs_proj-plsez = '20051121'.

gs_proj-postu = 'PROJECT DEFINITION IMN.IMN-BRA.05038'.

ENDFORM. " build_studio_proj_fields

CALL FUNCTION '2001_PROJECTDEF_CREATE'

EXPORTING

PROJECT_DEFINITION_STRU = gs_proj

IMPORTING

RETURN = gs_BAPIRETURN1

TABLES

E_MESSAGE_TABLE = gs_BAPI_METH_MESSAGE

.

<b>Also revise your build_studio_proj_fields routine logic accordingly.</b>

Sri

Message was edited by: Srikanth Pinnamaneni

0 Kudos

hi srikanth,

I have modified my code according to the steps given.

This time iam getting

Workarea gs_proj is long not enogh.

thanks,

Veeru

0 Kudos

Dont place * in the select query . use the req fields

Muthappan

0 Kudos

data: gp_proj type proj .

SELECT SINGLE * FROM PROJ INTO <b>gp_proj</b>

WHERE objnR = gv_objnr.

move-corresponding gp_proj to gs_proj .

CALL FUNCTION '2001_PROJECTDEF_CREATE'

EXPORTING

PROJECT_DEFINITION_STRU = gs_proj

IMPORTING

RETURN = gs_BAPIRETURN1

TABLES

E_MESSAGE_TABLE = gs_BAPI_METH_MESSAGE

Regards

Raja

0 Kudos

Hi,

Did you change the following part of the code?

FORM build_studio_proj_fields.

gv_objnr = 'PD00000093'.

****You cant use this now as gs_proj has a different ****structure.

<b>SELECT SINGLE * FROM PROJ INTO gs_proj

WHERE objnR = gv_objnr.</b>IF sy-subrc <> 0.

WRITE:/ 'There is some error'.

ENDIF.

****The following also has to be revised

CLEAR: gs_proj-pspnr, gs_proj-objnr.

gs_proj-pspid = 'IMN.IMN-BRA.05038'.

gs_proj-post1 = 'Pal Test project IMN.IMN-BRA.05038'.

gs_proj-ernam = 'XARMUGP'.

gs_proj-erdat = '20051121'.

gs_proj-plsez = '20051121'.

gs_proj-postu = 'PROJECT DEFINITION IMN.IMN-BRA.05038'.

ENDFORM. " build_studio_proj_fields

Change the above to the following,

FORM build_studio_proj_fields.

<b> DATA: ls_proj LIKE proj.</b>

gv_objnr = 'PD00000093'.

<b>SELECT SINGLE * FROM PROJ INTO ls_proj

WHERE objnR = gv_objnr.</b>IF sy-subrc <> 0.

WRITE:/ 'There is some error'.

ENDIF.

CLEAR: ls_proj-pspnr, ls_proj-objnr.

ls_proj-pspid = 'IMN.IMN-BRA.05038'.

ls_proj-post1 = 'Pal Test project IMN.IMN-BRA.05038'.

ls_proj-ernam = 'XARMUGP'.

ls_proj-erdat = '20051121'.

ls_proj-plsez = '20051121'.

ls_proj-postu = 'PROJECT DEFINITION IMN.IMN-BRA.05038'.

<b> call function 'MAP_PROJ_2_BAPI_PROJDEFINITION'

EXPORTING

proj = ls_proj

CHANGING

bapi2054_projdefinition = gs_proj

EXCEPTIONS

error_converting_keys = 1

others = 2.</b>

ENDFORM. " build_studio_proj_fields

Hope this helps..

Sri

0 Kudos

Hi srikant,

I did the samething.again short dump.

Can you give me ur mail id, so that i will forward my report.

Waiting for your response.

Veeru

0 Kudos

Hi,

You can email it at srikanth_sap@yahoo.com

Sri

0 Kudos

Hi Veeru,

I had sent you two emails yesterday itself with the revised code but it seems you did not receive them !!??

Dont you have a Yahoo id?

Any way, I am pasting the revised code here once again, so go through it. Changes are really in the subroutine <b>create_studio_project</b>. It works for me in my system.

Here is the code,

REPORT ZRPS_STUDIOPROJECT .

TABLES: csks.

*----


Constants

DATA : gc_zp(2) TYPE c VALUE 'ZP',

gc_zstu(4) TYPE c VALUE 'ZSTU'.

*----


Global variables

DATA : gv_bsart LIKE ekko-bsart,

gv_lifnr LIKE ekko-lifnr,

gv_objnr LIKE proj-objnr.

DATA : gs_proj LIKE bapi_project_definition.

DATA: ls_proj LIKE proj.

DATA : gs_bapireturn1 LIKE bapireturn1,

gs_bapi_project_definition_up LIKE bapi_project_definition_up.

DATA : gs_bapi_meth_message LIKE bapi_meth_message OCCURS 0 WITH HEADER

LINE,

gs_bapi_method_project LIKE bapi_method_project OCCURS 0 WITH

HEADER LINE,

gs_bapi_wbs_element LIKE bapi_wbs_element OCCURS 0 WITH HEADER

LINE.

*----


Types

TYPES : BEGIN OF gss_ekkn,

ebeln LIKE ekkn-ebeln,

ebelp LIKE ekkn-ebelp,

ps_psp_pnr LIKE ekkn-ps_psp_pnr,

END OF gss_ekkn,

gs_ekkn TYPE HASHED TABLE OF gss_ekkn WITH UNIQUE KEY ebeln.

DATA : gt_ekkn TYPE gs_ekkn WITH HEADER LINE.

DATA : BEGIN OF gt_prps OCCURS 0,

psphi LIKE prps-psphi,

END OF gt_prps.

*----


Selection Screen

PARAMETERS: p_ebeln TYPE ekko-ebeln.

START-OF-SELECTION.

PERFORM entry_neu USING 1 2.

END-OF-SELECTION.

----


  • FORM entry_neu *

----


  • ........ *

----


  • --> ENT_RETCO *

  • --> ENT_SCREEN *

----


FORM entry_neu USING ent_retco ent_screen.

  • Validate the PO type and vendor type

PERFORM validate_povendor_type.

  • Get the Agency Project Associated with the PO

PERFORM get_agency_project.

  • Build the required Studio project fields

PERFORM build_studio_proj_fields.

  • Call the function modules to create a Studio Project and commit

PERFORM create_studio_project.

ENDFORM.

&----


*& Form validate_povendor_type

&----


  • Here validate the PO is of type 'ZP' and the vendor number is of type

  • 'ZSTU'.

----


  • --> p1 text

  • <-- p2 text

----


FORM validate_povendor_type.

SELECT SINGLE bsart

lifnr

FROM ekko

INTO (gv_bsart,gv_lifnr)

WHERE ebeln = p_ebeln.

IF sy-subrc = 0.

IF gv_bsart <> gc_zp.

ENDIF.

IF gv_lifnr <> gc_zstu.

ENDIF.

ELSE.

ENDIF.

ENDFORM. " validate_info

&----


*& Form get_agency_project

&----


  • Here get the agency Project information. Use the WBS element used in

  • the Agency PO and get the project from PROJ

----


  • --> p1 text

  • <-- p2 text

----


FORM get_agency_project.

  • Get the WBS elements associated with the Agency PO.

SELECT ebeln

ebelp

ps_psp_pnr

FROM ekkn

INTO CORRESPONDING FIELDS OF gt_ekkn

WHERE ebeln = p_ebeln.

ENDSELECT.

  • Get the project associated with the Agency PO

  • This should give us the information like

SELECT psphi

FROM prps

INTO CORRESPONDING FIELDS OF gt_prps

FOR ALL ENTRIES IN gt_ekkn

WHERE pspnr = gt_ekkn-ps_psp_pnr.

ENDSELECT.

ENDFORM. " get_agency_project

&----


*& Form build_studio_proj_fields

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_studio_proj_fields.

gv_objnr = 'PD00000093'.

*SELECT SINGLE * FROM PROJ INTO gp_proj

*WHERE objnR = gv_objnr.

*

*move-corresponding gp_proj to gs_proj .

SELECT SINGLE * FROM proj INTO ls_proj

WHERE objnr = gv_objnr.

IF sy-subrc <> 0.

WRITE:/ 'There is some error'.

ENDIF.

CLEAR: ls_proj-pspnr, ls_proj-objnr.

ls_proj-pspid = 'IMN.IMN-BRA.05038'.

ls_proj-post1 = 'Pal Test project IMN.IMN-BRA.05038'.

ls_proj-ernam = 'XARMUGP'.

ls_proj-erdat = '20051121'.

ls_proj-plsez = '20051121'.

ls_proj-postu = 'PROJECT DEFINITION IMN.IMN-BRA.05038'.

.

ENDFORM. " build_studio_proj_fields

&----


*& Form create_studio_project

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


<b>FORM create_studio_project.

DATA: ls_proj_def_ex LIKE bapi_project_definition_ex,

ls_return LIKE bapireturn1,

lwa_message LIKE bapi_meth_message,

lt_messages TYPE TABLE OF bapi_meth_message INITIAL SIZE 0.

  • CALL FUNCTION 'CJWB_CREATE_PROJ'

  • EXPORTING

  • I_PROJ = gs_proj

  • EXCEPTIONS

  • PROJECT_EXIST = 1

  • STRU_GESP = 2

  • WRONG_PROFILE = 3

  • PROJ_GESPERRT = 4

  • WRONG_STSMA = 5

  • WRONG_STSMA_OB = 6

  • OTHERS = 7

  • .

  • IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

*

*

  • ELSE.

    • CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

  • ENDIF.

  • commit work and wait.

        • TO CREATE PROJECT DEFINITON

    • CALL FUNCTION 'BAPI_PROJECTDEF_CREATE'

    • EXPORTING

    • PROJECT_DEFINITION_STRU = gs_proj

    • IMPORTING

    • RETURN = gs_BAPIRETURN1

    • TABLES

    • E_MESSAGE_TABLE = gs_BAPI_METH_MESSAGE.

    • COMMIT WORK.

**

*CALL FUNCTION '2001_PROJECTDEF_CREATE'

  • EXPORTING

  • PROJECT_DEFINITION_STRU = gs_proj

  • IMPORTING

  • RETURN = gs_BAPIRETURN1

  • TABLES

  • E_MESSAGE_TABLE = gs_BAPI_METH_MESSAGE

  • .

    • TO CREATE WBS-ELEMENT.

  • CALL FUNCTION 'BAPI_PROJECT_MAINTAIN'

  • EXPORTING

  • I_PROJECT_DEFINITION = gs_proj

  • I_PROJECT_DEFINITION_UPD = gs_BAPI_PROJECT_DEFINITION_UP

  • IMPORTING

  • RETURN = gs_BAPIRETURN1

  • TABLES

  • I_METHOD_PROJECT = gs_BAPI_METHOD_PROJECT

  • I_WBS_ELEMENT_TABLE = gs_BAPI_WBS_ELEMENT

  • E_MESSAGE_TABLE = gs_BAPI_METH_MESSAGE.

  • COMMIT WORK.

CALL FUNCTION 'MAP_PROJ_2_BAPI_PROJECTDEF_EX'

EXPORTING

i_proj = ls_proj

CHANGING

bapi_project_definition = ls_proj_def_ex.

MOVE-CORRESPONDING ls_proj_def_ex TO gs_proj.

CALL FUNCTION 'BAPI_PROJECTDEF_CREATE'

EXPORTING

project_definition_stru = gs_proj

IMPORTING

return = ls_return

TABLES

e_message_table = lt_messages[].

IF NOT ls_return IS INITIAL.

ENDIF.

ENDFORM. " create_studio_project</b>

Sri