Skip to Content
author's profile photo
Former Member

Very Critical!!!! Please!! Please!! help me on this

Hi

This is very critical, please give me a solution... if you want i will send you the whole code of the program.

Below is the code of the program:

*----


*

  • read a message short and long text using the BAPI *

  • BAPI_MESSAGE_GETDETAIL of the object BapiService. *

*----


*

REPORT ZSRJVBAPI.

TYPES: BEGIN OF TY_PRCTR_KEY,

PRCTR TYPE PRCTR,

DATBI TYPE DATBI,

END OF TY_PRCTR_KEY.

TYPES: TY_T_PRCTR_KEY TYPE TABLE OF TY_PRCTR_KEY WITH KEY PRCTR,

TY_T_BUKRS TYPE TABLE OF BUKRS.

  • Data declaration

DATA: GT_PRCT1_BUKRS TYPE TABLE OF PRCT1_BUKRS,

GS_PRCT1_BUKRS TYPE PRCT1_BUKRS,

GT_PRCT1_BUKRSX TYPE TABLE OF PRCT1_BUKRSX,

GS_PRCT1_BUKRSX TYPE PRCT1_BUKRSX,

GT_BUKRS TYPE TY_T_BUKRS,

GD_BUKRS TYPE BUKRS,

GS_TESTRUN TYPE BAPI0015_9,

GS_PRCTR_DATA TYPE PRCT1,

GS_PRCTR_DATAX TYPE PRCT1X,

GD_PRCTR TYPE PRCTR,

GS_TKA01 TYPE TKA01,

GS_PRCTR TYPE TY_PRCTR_KEY,

GT_PRCTR TYPE TY_T_PRCTR_KEY,

GS_BAPIRET1 TYPE BAPIRET2,

GS_BAPIRET2 TYPE BAPIRET2,

GD_LOG_HANDLE TYPE BALLOGHNDL,

GS_LOG TYPE BAL_S_LOG,

GS_MSG TYPE BAL_S_MSG,

GS_CONTEXT TYPE BAPI0015ID2,

GS_DISPLAY_PROFILE TYPE BAL_S_PROF,

GS_FCAT TYPE BAL_S_FCAT.

DATA: BEGIN OF GS_JVDAT OCCURS 0.

DATA: BUKRS LIKE GD_BUKRS.

INCLUDE STRUCTURE GJV_DATA.

DATA: END OF GS_JVDAT.

SELECTION-SCREEN BEGIN OF BLOCK SELECTION WITH FRAME.

PARAMETERS: P_KOKRS TYPE PRCT1-KOKRS VALUE CHECK OBLIGATORY,

P_GROUP TYPE PRCT1-KHINR.

SELECT-OPTIONS: SO_PRCTR FOR GD_PRCTR.

SELECT-OPTIONS: SO_BUKRS FOR GD_BUKRS.

SELECTION-SCREEN SKIP.

SELECTION-SCREEN END OF BLOCK SELECTION.

SELECTION-SCREEN BEGIN OF BLOCK MARK WITH FRAME.

*PARAMETERS: P_ASSIGN

  • TYPE PRCT1_BUKRS-ASSIGN_TO_PRCTR RADIOBUTTON GROUP MARK,

  • P_DISPLY

  • TYPE PRCT1_BUKRS-ASSIGN_TO_PRCTR RADIOBUTTON GROUP MARK.

PARAMETERS: P_TEST TYPE TESTRUN DEFAULT ' ',

P_NO_CCC TYPE BOOLE_D DEFAULT SPACE NO-DISPLAY.

SELECTION-SCREEN END OF BLOCK MARK.

SELECTION-SCREEN BEGIN OF BLOCK FILE WITH FRAME.

PARAMETERS: P_FILE TYPE RLGRAP-FILENAME.

SELECTION-SCREEN END OF BLOCK FILE.

INITIALIZATION.

GET PARAMETER ID 'CAC' FIELD P_KOKRS.

AT SELECTION-SCREEN.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_GROUP.

SELECT SINGLE * FROM TKA01 INTO GS_TKA01 WHERE KOKRS = P_KOKRS.

  • authority check for groups

AUTHORITY-CHECK OBJECT 'K_PCAP_SET'

ID 'KOKRS' FIELD P_KOKRS

ID 'ACTVT' FIELD '03'.

IF SY-SUBRC <> 0.

MESSAGE E734(KH) WITH P_KOKRS.

ENDIF.

PERFORM SET_HELP IN PROGRAM SAPMKEC1

USING 'CEPC '

'KHINR '

GS_TKA01-PHINR

GS_TKA01-KOKRS

SPACE

CHANGING P_GROUP.

IF P_GROUP IS INITIAL AND SO_PRCTR[] IS INITIAL.

MESSAGE W013(Z5).

SET SCREEN SY-DYNNR.

LEAVE SCREEN.

ENDIF.

IF NOT SO_PRCTR IS INITIAL.

IF SO_PRCTR-LOW = '0000000000' AND

SO_PRCTR-HIGH = '9999999999'.

MESSAGE W011(Z5).

ENDIF.

ENDIF.

IF NOT P_GROUP IS INITIAL AND

P_GROUP = 'AMOCO_HIER'.

MESSAGE W014(Z5).

ENDIF.

IF NOT P_GROUP IS INITIAL AND NOT SO_PRCTR[] IS INITIAL.

MESSAGE E051(KM).

ENDIF.

START-OF-SELECTION.

PERFORM GET_PRCTR_AND_BUKRS TABLES GT_BUKRS

GT_PRCTR.

PERFORM GET_JV_DATA.

*END-OF-SELECTION.

  • build up the call table for companycodes

LOOP AT GT_BUKRS INTO GD_BUKRS.

LOOP AT GS_JVDAT WHERE BUKRS = GD_BUKRS.

GS_PRCT1_BUKRS-COMP_CODE = GD_BUKRS.

GS_PRCT1_BUKRS-ASSIGN_TO_PRCTR = 'X'.

GS_PRCT1_BUKRS-VNAME = GS_JVDAT-VNAME.

GS_PRCT1_BUKRS-RECID = GS_JVDAT-RECID.

GS_PRCT1_BUKRS-ETYPE = GS_JVDAT-ETYPE.

GS_PRCT1_BUKRS-JV_OTYPE = GS_JVDAT-OTYPE.

GS_PRCT1_BUKRS-JV_JIBCL = GS_JVDAT-JIBCL.

GS_PRCT1_BUKRS-JV_JIBSA = GS_JVDAT-JIBSA.

APPEND GS_PRCT1_BUKRS TO GT_PRCT1_BUKRS.

  • prepare xbar for function call

GS_PRCT1_BUKRSX-COMP_CODE = GD_BUKRS.

GS_PRCT1_BUKRSX-ASSIGN_TO_PRCTR = 'X'. "relevant for change

GS_PRCT1_BUKRSX-VNAME = 'X'.

GS_PRCT1_BUKRSX-RECID = 'X'.

GS_PRCT1_BUKRSX-ETYPE = 'X'.

GS_PRCT1_BUKRSX-JV_OTYPE = 'X'.

GS_PRCT1_BUKRSX-JV_JIBCL = 'X'.

GS_PRCT1_BUKRSX-JV_JIBSA = 'X'.

APPEND GS_PRCT1_BUKRSX TO GT_PRCT1_BUKRSX.

ENDLOOP.

ENDLOOP.

  • create an initial log file

GS_LOG-EXTNUMBER =

'Ergebnisse der Buchungskreisänderung'(001).

CALL FUNCTION 'BAL_LOG_CREATE'

EXPORTING

I_S_LOG = GS_LOG

IMPORTING

E_LOG_HANDLE = GD_LOG_HANDLE

EXCEPTIONS

OTHERS = 1.

IF SY-SUBRC <> 0.

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

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

ENDIF.

  • GS_TESTRUN-TESTRUN = P_TEST.

  • call the change function module

LOOP AT GT_PRCTR INTO GS_PRCTR.

GS_PRCTR_DATA-PRCTR = GS_PRCTR-PRCTR.

GS_PRCTR_DATA-KOKRS = P_KOKRS.

GS_PRCTR_DATA-KHINR = P_GROUP.

GS_PRCTR_DATA-DATAB = GS_PRCTR-DATBI.

GS_PRCTR_DATA-DATBI = GS_PRCTR-DATBI.

CLEAR GS_BAPIRET2.

CALL FUNCTION 'PROFITCENTER_CHANGE'

EXPORTING

PRCTR_DATA = GS_PRCTR_DATA "

PRCTR_DATAX = GS_PRCTR_DATAX "empty

NO_CCODES_CHECK = P_NO_CCC

COMPLETE = ' '

INACTIVE_VERSION = 'X'

TESTRUN = ' '

INSERT_MODE = ' '

IMPORTING

RETURN = GS_BAPIRET2

TABLES

COMPANYCODE_JOINT_VENTURE = GT_PRCT1_BUKRS

COMPANYCODE_JOINT_VENTUREX = GT_PRCT1_BUKRSX.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = '2'

IMPORTING

RETURN = GS_BAPIRET1.

GS_MSG-MSGTY = GS_BAPIRET2-TYPE.

GS_MSG-MSGID = GS_BAPIRET2-ID.

GS_MSG-MSGNO = GS_BAPIRET2-NUMBER.

GS_MSG-MSGV1 = GS_BAPIRET2-MESSAGE_V1.

GS_MSG-MSGV2 = GS_BAPIRET2-MESSAGE_V2.

GS_MSG-MSGV3 = GS_BAPIRET2-MESSAGE_V3.

GS_MSG-MSGV4 = GS_BAPIRET2-MESSAGE_V4.

GS_CONTEXT-CO_AREA = P_KOKRS.

GS_CONTEXT-PROFIT_CTR = GS_PRCTR-PRCTR.

GS_MSG-CONTEXT-TABNAME = 'BAPI0015ID2'.

GS_MSG-CONTEXT-VALUE = GS_CONTEXT.

CALL FUNCTION 'BAL_LOG_MSG_ADD'

EXPORTING

I_LOG_HANDLE = GD_LOG_HANDLE

I_S_MSG = GS_MSG

EXCEPTIONS

OTHERS = 1.

IF SY-SUBRC <> 0.

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

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

ENDIF.

ENDLOOP.

  • get display profile

CALL FUNCTION 'BAL_DSP_PROFILE_NO_TREE_GET'

IMPORTING

E_S_DISPLAY_PROFILE = GS_DISPLAY_PROFILE

EXCEPTIONS

OTHERS = 1.

IF SY-SUBRC <> 0.

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

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

ENDIF.

  • use grid for display if wanted

  • gs_display_profile-use_grid = 'X'.

  • set report to allow saving of variants

GS_DISPLAY_PROFILE-DISVARIANT-REPORT = SY-REPID.

  • when you use also other ALV lists in your report,

  • please specify a handle to distinguish between the display

  • variants of these different lists, e.g:

GS_DISPLAY_PROFILE-DISVARIANT-HANDLE = 'LOG'.

  • set header for display

IF P_TEST = 'X'.

CONCATENATE TEXT-001 TEXT-002 INTO GS_DISPLAY_PROFILE-TITLE.

ELSE.

GS_DISPLAY_PROFILE-TITLE = TEXT-001.

ENDIF.

  • display the message's context as well: prctr, controllingarea

GS_FCAT-REF_TABLE = 'BAPI0015ID2'.

GS_FCAT-REF_FIELD = 'CO_AREA'.

APPEND GS_FCAT TO GS_DISPLAY_PROFILE-MESS_FCAT.

GS_FCAT-REF_TABLE = 'BAPI0015ID2'.

GS_FCAT-REF_FIELD = 'PROFIT_CTR'.

APPEND GS_FCAT TO GS_DISPLAY_PROFILE-MESS_FCAT.

  • call display function module

CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'

EXPORTING

I_S_DISPLAY_PROFILE = GS_DISPLAY_PROFILE

EXCEPTIONS

OTHERS = 1.

IF SY-SUBRC <> 0.

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

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

ENDIF.

*&----


*

*& Form get_prctr_and_bukrs

*&----


*

  • text

*----


*

  • -->P_LT_BUKRS text

  • -->P_LT_PRCTR text

*----


*

FORM GET_PRCTR_AND_BUKRS TABLES PT_BUKRS

PT_PRCTR.

DATA: LD_BUKRS TYPE BUKRS,

BEGIN OF LS_PRCTR,

PRCTR TYPE PRCTR,

DATBI TYPE DATBI,

END OF LS_PRCTR,

LT_PRCTR LIKE TABLE OF LS_PRCTR WITH KEY PRCTR,

LD_GROUPNAME TYPE SETHIER_CO-GROUPNAME,

LT_SETHIER TYPE TABLE OF SETHIER_CO,

LT_SETVAL TYPE TABLE OF SETVAL_CO,

LS_SETVAL TYPE SETVAL_CO,

LD_PACKAGE_SIZE TYPE I VALUE '500',

SO2_PRCTR TYPE RANGE OF PRCTR,

LD_NUM TYPE I,

LS_BAPIRET2 TYPE BAPIRET2.

  • general authority check for display (change authority is checked

  • in 'profitcenter_change')

AUTHORITY-CHECK OBJECT 'K_PCAS_PRC'

ID 'KOKRS' FIELD P_KOKRS

ID 'ACTVT' FIELD '03'.

IF SY-SUBRC <> 0.

MESSAGE E741(KH) WITH P_KOKRS.

ENDIF.

  • selection part

IF NOT P_GROUP IS INITIAL.

LD_GROUPNAME = P_GROUP.

CALL FUNCTION 'K_GROUP_REMOTE_READ'

EXPORTING

SETCLASS = '0106'

CO_AREA = P_KOKRS

  • CHRT_ACCTS =

GROUPNAME = LD_GROUPNAME

  • LANGUAGE =

  • IMPORTING

  • RETURN =

TABLES

ET_SETHIER = LT_SETHIER

ET_SETVAL = LT_SETVAL.

IF LS_BAPIRET2-TYPE CA 'AEW'.

MESSAGE ID LS_BAPIRET2-ID

TYPE 'E'

NUMBER LS_BAPIRET2-NUMBER

WITH LS_BAPIRET2-MESSAGE_V1

LS_BAPIRET2-MESSAGE_V2

LS_BAPIRET2-MESSAGE_V3

LS_BAPIRET2-MESSAGE_V4.

ENDIF.

LOOP AT LT_SETVAL INTO LS_SETVAL.

SO_PRCTR-SIGN = 'I'.

SO_PRCTR-OPTION = 'BT'.

SO_PRCTR-LOW = LS_SETVAL-VALFROM.

SO_PRCTR-HIGH = LS_SETVAL-VALTO.

APPEND SO_PRCTR.

ENDLOOP.

ENDIF.

  • transform select options into internal tables

SELECT BUKRS FROM TKA02 INTO TABLE PT_BUKRS[]

WHERE KOKRS = P_KOKRS

AND BUKRS IN SO_BUKRS.

  • read by package

LOOP AT SO_PRCTR.

IF LD_NUM = LD_PACKAGE_SIZE.

SELECT PRCTR DATBI FROM CEPC INTO TABLE LT_PRCTR

WHERE KOKRS = P_KOKRS

AND PRCTR IN SO2_PRCTR.

CLEAR: LD_NUM, SO2_PRCTR.

REFRESH SO2_PRCTR.

ENDIF.

APPEND SO_PRCTR TO SO2_PRCTR.

LD_NUM = LD_NUM + 1.

ENDLOOP.

  • last package

SELECT PRCTR DATBI FROM CEPC INTO TABLE LT_PRCTR

WHERE KOKRS = P_KOKRS

AND PRCTR IN SO2_PRCTR.

SORT LT_PRCTR.

DELETE ADJACENT DUPLICATES FROM LT_PRCTR.

LOOP AT LT_PRCTR INTO LS_PRCTR.

  • authority check for profitcenters

CALL FUNCTION 'K_PCA_RESP_AUTHORITY_CHECK'

EXPORTING

I_KOKRS = P_KOKRS

I_PRCTR = LS_PRCTR-PRCTR

I_VORGN = 'STDT' "Master Data

I_ACTVT = '03'

I_NO_DIALOG_MESSAGE = 'X' "note 447948

EXCEPTIONS

NO_AUTHORITY = 1

DATA_MISSING = 2

OTHERS = 3.

CASE SY-SUBRC.

WHEN 0.

WHEN 1.

  • authority error

MESSAGE ID SY-MSGID TYPE 'E' NUMBER SY-MSGNO

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

WHEN OTHERS.

  • stop

MESSAGE ID SY-MSGID TYPE 'A' NUMBER SY-MSGNO

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

ENDCASE.

ENDLOOP.

PT_PRCTR[] = LT_PRCTR[].

ENDFORM. " get_prctr_and_bukrs

*&----


*

*& Form GET_JV_DATA

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

FORM GET_JV_DATA.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = P_FILE

FILETYPE = 'ASC'

TABLES

DATA_TAB = GS_JVDAT

EXCEPTIONS

CONVERSION_ERROR = 1

FILE_OPEN_ERROR = 2

FILE_READ_ERROR = 3

INVALID_TYPE = 4

NO_BATCH = 5

UNKNOWN_ERROR = 6

INVALID_TABLE_WIDTH = 7

GUI_REFUSE_FILETRANSFER = 8

CUSTOMER_ERROR = 9

OTHERS = 10.

IF SY-SUBRC <> 0.

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

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

ENDIF.

ENDFORM. " GET_JV_DATA

-

-


The test file should be in the below format:

-

-


BUKRS, Venture Name, RECID, ETYPE, OTYPE

0605BL0085CP1 1

Thank You,

Suresh

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • author's profile photo
    Former Member
    Oct 04, 2005 at 02:50 PM

    The program uses a BAPI to change the profit centers to upload the Joint Venture data.

    This program gives the message that Profit center is changed successfully but its not showing the contents of the Joint Venture

    Please help me out on this.

    Thank You

    Suresh

    Add comment
    10|10000 characters needed characters exceeded