Skip to Content
author's profile photo Former Member
Former Member

BDC FOR PA30

Hi,

I did a recording for transaction pa30 infotype 0000

The following is my coding

report ZBKT_P0000

no standard page heading line-size 255.

*******************Type Pools*****************************

TYPE-POOLS : TRUXS.

include bdcrecx1.

*****************Internal Tables**************************

DATA : BEGIN OF IT_DATA OCCURS 0,

pernr LIKE rp50g-pernr,

begda LIKE p0000-begda,

massg LIKE p0000-massg,

plans LIKE pspar-plans,

werks LIKE pspar-werks,

persg LIKE pspar-persg,

persk LIKE pspar-persk,

END OF IT_DATA.

DATA : IT_RAW TYPE TRUXS_T_TEXT_DATA.

DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

DATA : IT_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

*******************Selection Screen***********************

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETER P_FILE TYPE RLGRAP-FILENAME OBLIGATORY.

SELECTION-SCREEN END OF BLOCK B1.

****************At Selection Screen***********************

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

PERFORM HELP_FILE USING P_FILE.

***************Start Of Selection*************************

START-OF-SELECTION.

PERFORM UPLOAD_FILE USING P_FILE.

PERFORM POPULATE_FILE.

&----


*& Form HELP_FILE

&----


  • text

----


  • -->P_P_FILE text

----


FORM HELP_FILE USING P_P_FILE.

DATA: L_FILE TYPE IBIPPARMS-PATH.

CALL FUNCTION 'F4_FILENAME'

  • EXPORTING

  • PROGRAM_NAME = SYST-CPROG

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

IMPORTING

FILE_NAME = L_FILE.

P_P_FILE = L_FILE.

ENDFORM. " HELP_FILE

&----


*& Form UPLOAD_FILE

&----


  • text

----


  • -->P_P_FILE text

----


FORM UPLOAD_FILE USING P_P_FILE.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

  • I_FIELD_SEPERATOR =

I_LINE_HEADER = 'X'

I_TAB_RAW_DATA = IT_RAW

I_FILENAME = P_FILE

TABLES

I_TAB_CONVERTED_DATA = IT_DATA[]

EXCEPTIONS

CONVERSION_FAILED = 1

OTHERS = 2

.

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. " UPLOAD_FILE

&----


*& Form POPULATE_FILE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM POPULATE_FILE .

CLEAR NODATA.

*perform open_group.

LOOP AT IT_DATA.

perform bdc_dynpro using 'SAPMP50A' '1000'.

perform bdc_field using 'BDC_OKCODE'

'=INS'.

perform bdc_field using 'RP50G-PERNR'

IT_DATA-PERNR.

perform bdc_field using 'RP50G-TIMR6'

'X'.

perform bdc_field using 'BDC_CURSOR'

'RP50G-CHOIC'.

perform bdc_field using 'RP50G-CHOIC'

'0'.

perform bdc_dynpro using 'SAPLRHWH' '0400'.

perform bdc_field using 'BDC_OKCODE'

'=%_GC 116 25'.

perform bdc_dynpro using 'MP000000' '2000'.

perform bdc_field using 'BDC_CURSOR'

'PSPAR-PERSK'.

perform bdc_field using 'BDC_OKCODE'

'=UPD'.

perform bdc_field using 'PSPAR-PERNR'

' 1006'.

perform bdc_field using 'P0000-BEGDA'

IT_DATA-BEGDA.

perform bdc_field using 'P0000-ENDDA'

'31.12.9999'.

perform bdc_field using 'P0000-MASSN'

'01'.

perform bdc_field using 'P0000-MASSG'

IT_DATA-MASSG.

perform bdc_field using 'PSPAR-PLANS'

IT_DATA-PLANS.

perform bdc_field using 'PSPAR-WERKS'

IT_DATA-WERKS.

perform bdc_field using 'PSPAR-PERSG'

IT_DATA-PERSG.

perform bdc_field using 'PSPAR-PERSK'

IT_DATA-PERSK.

perform bdc_dynpro using 'MP000200' '2040'.

perform bdc_field using 'BDC_OKCODE'

'/ENXT'.

perform bdc_field using 'BDC_CURSOR'

'P0002-BEGDA'.

perform bdc_dynpro using 'MP000100' '2000'.

perform bdc_field using 'BDC_OKCODE'

'/ENXT'.

perform bdc_field using 'BDC_CURSOR'

'P0001-BEGDA'.

perform bdc_dynpro using 'SAPLSPO1' '0200'.

perform bdc_field using 'BDC_OKCODE'

'=YES'.

perform bdc_dynpro using 'MP000600' '2000'.

perform bdc_field using 'BDC_OKCODE'

'/ENXT'.

perform bdc_field using 'BDC_CURSOR'

'P0006-BEGDA'.

perform bdc_dynpro using 'MP000700' '2000'.

perform bdc_field using 'BDC_OKCODE'

'/ENXT'.

perform bdc_field using 'BDC_CURSOR'

'P0007-BEGDA'.

perform bdc_dynpro using 'MP000800' '2040'.

perform bdc_field using 'BDC_OKCODE'

'/ENXT'.

perform bdc_field using 'BDC_CURSOR'

'P0008-BEGDA'.

perform bdc_dynpro using 'MP000900' '2000'.

perform bdc_field using 'BDC_OKCODE'

'/ENXT'.

perform bdc_field using 'BDC_CURSOR'

'P0009-BEGDA'.

perform bdc_dynpro using 'MP200000' '2251'.

perform bdc_field using 'BDC_OKCODE'

'/ENXT'.

perform bdc_field using 'BDC_CURSOR'

'RP50M-BEGDA'.

perform bdc_dynpro using 'SAPLSPO1' '0200'.

perform bdc_field using 'BDC_OKCODE'

'=YES'.

perform bdc_transaction using 'PA30'.

ENDLOOP.

*perform close_group.

ENDFORM. " POPULATE_FILE

*************************************

While executing i get a popup saying bdc_inser session not opened...

Plz reply.....

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 06:56 AM

    Hi,

    Did you call the FM BDC_OPEN_GROUP before BDC_INSERT..

    Regards

    Kiran Sure

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 06:59 AM

    Hi

    Cud ugive a more detailed explanation

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Ankit,

      Please refer the below code for your reference:

      &----


      *& Report ZBDC_TAB_CTRL_FB50 *

      *& *

      &----


      *& *

      *& *

      &----


      REPORT ZBDC_TAB_CTRL_FB50 .

      DATA: I_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

      ****Header Internal Table

      DATA: BEGIN OF T_HEAD OCCURS 0,

      BLDAT(10) TYPE C,

      BUDAT(10) TYPE C,

      END OF T_HEAD.

      ****Detail Internal Table

      DATA: BEGIN OF T_DET OCCURS 0,

      BLDAT(10) TYPE C,

      BUDAT(10) TYPE C,

      HKONT LIKE ACGL_ITEM-HKONT,

      SHKZG LIKE ACGL_ITEM-SHKZG,

      WRBTR(16) TYPE C,

      END OF T_DET.

      DATA: T_EXCEL LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE,

      IDX(2) TYPE C,

      FNAM(20) TYPE C,

      FVAL(40) TYPE C.

      ***Internal Table for Holding Messages

      DATA: BEGIN OF MSGTAB OCCURS 0.

      INCLUDE STRUCTURE BDCMSGCOLL.

      DATA: END OF MSGTAB.

      Parameter for locating the .xls file

      PARAMETER:P_FILE TYPE RLGRAP-FILENAME OBLIGATORY.

      ***Selection Block for Header Section

      SELECTION-SCREEN : BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.

      PARAMETER: PBROW_HD TYPE I,

      PEROW_HD TYPE I,

      PBCOL_HD TYPE I,

      PECOL_HD TYPE I.

      SELECTION-SCREEN : END OF BLOCK BLK1.

      ***Selection Block for Detail Section

      SELECTION-SCREEN : BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-002.

      PARAMETER: PBROW_DT TYPE I,

      PEROW_DT TYPE I,

      PBCOL_DT TYPE I,

      PECOL_DT TYPE I.

      SELECTION-SCREEN : END OF BLOCK BLK2.

      ****Selecting the

      AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

      CALL FUNCTION 'F4_FILENAME'

      EXPORTING

      PROGRAM_NAME = SYST-CPROG

      DYNPRO_NUMBER = SYST-DYNNR

      FIELD_NAME = ' '

      IMPORTING

      FILE_NAME = P_FILE.

      START-OF-SELECTION.

      ***Selecting data from .xls for the header data

      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

      EXPORTING

      FILENAME = P_FILE

      I_BEGIN_COL = PBCOL_HD

      I_BEGIN_ROW = PBROW_HD

      I_END_COL = PECOL_HD

      I_END_ROW = PEROW_HD

      TABLES

      INTERN = T_EXCEL

      EXCEPTIONS

      INCONSISTENT_PARAMETERS = 1

      UPLOAD_OLE = 2

      OTHERS = 3.

      IF SY-SUBRC 0.

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

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

      ENDIF.

      ****For Header internal Table

      LOOP AT T_EXCEL WHERE ROW GT 0.

      CASE T_EXCEL-COL.

      WHEN 1. MOVE T_EXCEL-VALUE TO T_HEAD-BLDAT.

      WHEN 2. MOVE T_EXCEL-VALUE TO T_HEAD-BUDAT.

      ENDCASE.

      AT END OF ROW.

      APPEND T_HEAD.

      CLEAR T_HEAD.

      ENDAT.

      ENDLOOP.

      ***Selecting data from .xls for the detail data

      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

      EXPORTING

      FILENAME = P_FILE

      I_BEGIN_COL = PBCOL_DT

      I_BEGIN_ROW = PBROW_DT

      I_END_COL = PECOL_DT

      I_END_ROW = PEROW_DT

      TABLES

      INTERN = T_EXCEL

      EXCEPTIONS

      INCONSISTENT_PARAMETERS = 1

      UPLOAD_OLE = 2

      OTHERS = 3.

      IF SY-SUBRC 0.

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

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

      ENDIF.

      ****For Detail internal Table

      LOOP AT T_EXCEL WHERE ROW GT 0.

      CASE T_EXCEL-COL.

      WHEN 1. MOVE T_EXCEL-VALUE TO T_DET-BLDAT.

      WHEN 2. MOVE T_EXCEL-VALUE TO T_DET-BUDAT.

      WHEN 3. MOVE T_EXCEL-VALUE TO T_DET-HKONT.

      WHEN 4. MOVE T_EXCEL-VALUE TO T_DET-SHKZG.

      WHEN 5. MOVE T_EXCEL-VALUE TO T_DET-WRBTR.

      ENDCASE.

      AT END OF ROW.

      APPEND T_DET.

      CLEAR T_DET.

      ENDAT.

      ENDLOOP.

      ***Populating i_bdcdata from the header internal table

      LOOP AT T_HEAD .

      PERFORM BDC USING 'H'.

      ***Populating i_bdcdata from the detail internal table

      LOOP AT T_DET WHERE BLDAT = T_HEAD-BLDAT AND

      BUDAT = T_HEAD-BUDAT.

      PERFORM BDC USING 'D'.

      ENDLOOP.

      PERFORM POPULATE_BDCTABLE USING:'' 'BDC_OKCODE' '=BU'.

      CALL TRANSACTION 'FB50' USING I_BDCDATA

      MODE 'A'

      UPDATE 'A'.

      ENDLOOP.

      &----


      *& Form POPULATE_BDCTABLE

      &----


      text

      -


      -->P_0011 text

      -->P_0012 text

      -->P_0013 text

      -


      FORM POPULATE_BDCTABLE USING VALUE(P_FLAG)

      VALUE(P_FNAM)

      VALUE(P_FVAL).

      IF P_FLAG = 'X'.

      I_BDCDATA-PROGRAM = P_FNAM.

      I_BDCDATA-DYNPRO = P_FVAL.

      I_BDCDATA-DYNBEGIN = 'X'.

      ELSE.

      I_BDCDATA-FNAM = P_FNAM.

      I_BDCDATA-FVAL = P_FVAL.

      ENDIF.

      APPEND I_BDCDATA.

      CLEAR I_BDCDATA.

      ENDFORM. " POPULATE_BDCTABLE

      &----


      *& Form BDC

      &----


      text

      -


      -->P_0416 text

      -


      FORM BDC USING VALUE(P_VAL).

      ****For Header

      IF P_VAL = 'H'.

      DATA:L_BLDAT(10) TYPE C,

      L_BUDAT(10) TYPE C.

      CLEAR:L_BLDAT,L_BUDAT.

      WRITE: T_HEAD-BLDAT TO L_BLDAT,

      T_HEAD-BUDAT TO L_BUDAT.

      PERFORM POPULATE_BDCTABLE USING:'X' 'SAPMF05A' '1001',

      ' ' 'BDC_OKCODE' '=0006',

      ' ' 'BDC_CURSOR' 'ACGL_ITEM-WRBTR(01)',

      ' ' 'ACGL_HEAD-BLDAT' L_BLDAT,

      ' ' 'ACGL_HEAD-BUDAT' L_BUDAT .

      ****For Detail

      ELSEIF P_VAL = 'D'.

      IDX = IDX + 1.

      IF IDX = 1.

      CONCATENATE 'ACGL_ITEM-HKONT(0' IDX ')' INTO FNAM.

      PERFORM POPULATE_BDCTABLE USING: ' ' FNAM T_DET-HKONT.

      CONCATENATE 'ACGL_ITEM-SHKZG(0' IDX ')' INTO FNAM.

      PERFORM POPULATE_BDCTABLE USING ' ' FNAM T_DET-SHKZG.

      CONCATENATE 'ACGL_ITEM-WRBTR(0' IDX ')' INTO FNAM.

      PERFORM POPULATE_BDCTABLE USING ' ' FNAM T_DET-WRBTR.

      ELSE.

      IF IDX > 10.

      IDX = 10.

      ENDIF.

      PERFORM POPULATE_BDCTABLE USING: 'X' 'SAPMF05A' '1001',

      ' ' 'BDC_OKCODE' '=0006'.

      CONCATENATE 'ACGL_ITEM-HKONT(0' IDX ')' INTO FNAM.

      PERFORM POPULATE_BDCTABLE USING: ' ' FNAM T_DET-HKONT.

      CONCATENATE 'ACGL_ITEM-SHKZG(0' IDX ')' INTO FNAM.

      PERFORM POPULATE_BDCTABLE USING ' ' FNAM T_DET-SHKZG.

      CONCATENATE 'ACGL_ITEM-WRBTR(0' IDX ')' INTO FNAM.

      PERFORM POPULATE_BDCTABLE USING ' ' FNAM T_DET-WRBTR.

      ENDIF.

      ENDIF.

      ENDFORM. " BDC

      Thanks.

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 01:33 PM

    Include the STD pgm

    INCLUDE BDCRECXX.

    befor u perform perform bdc_field

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 01:49 PM

    Hi Ankit

    I see that you are recording Infotypes 0, 1, 8, 9 etc

    What is that you are trying to acheive in this? Are you trying to do a personal action PA40?

    After you have entered data into a infotype (say 0000)

    you need to do

    PERFORM bdc_insert USING 'PA30'.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      LOOP AT itab.

      PERFORM build_sessions.

      CLEAR: bdcdata, bdcdata[].

      • PA30 initial Screen

      PERFORM bdc_program USING 'SAPMP50A' '1000'.

      PERFORM bdc_fields USING : 'RP50G-PERNR' itab-persnr,

      'RP50G-CHOIC' '0001',

      'bdc_okcode' 'MOD'.

      PERFORM bdc_program USING 'MP905000' '2000'.

      PERFORM bdc_fields USING :

      'P0001-BEGDA' begdat,

      'P0001-ENDDA' enddat,

      • Other fields you want

      'BDC_OKCODE' '=UPD'.

      PERFORM bdc_insert USING 'PA30'.

      record_count = record_count + 1.

      ENDLOOP.

      Include these subroutines or create an include with this code

      Call the include in your program

      &----


      *& Form BUILD_SESSIONS

      &----


      • *

      ----


      FORM BUILD_SESSIONS.

      IF RECORD_COUNT = 0.

      PERFORM APPEND_SESSION.

      PERFORM BDC_OPEN_GROUP.

      ENDIF.

      IF RECORD_COUNT > P_LIMIT.

      PERFORM BDC_CLOSE_GROUP.

      PERFORM APPEND_SESSION.

      PERFORM BDC_OPEN_GROUP.

      RECORD_COUNT = 0.

      ENDIF.

      ENDFORM. " BUILD_SESSIONS

      &----


      *& Form APPEND_SESSION

      &----


      • text *

      ----


      FORM APPEND_SESSION.

      SESSION_COUNT = SESSION_COUNT + 1.

      SESSION_NAME = P_SNAME.

      SESSION_NAME+9(2) = SESSION_COUNT.

      CONDENSE SESSION_NAME NO-GAPS.

      ENDFORM. " APPEND_SESSION

      &----


      *& Form BDC_OPEN_GROUP

      &----


      • text *

      ----


      FORM BDC_OPEN_GROUP.

      CALL FUNCTION 'BDC_OPEN_GROUP'

      EXPORTING

      CLIENT = SY-MANDT

      GROUP = SESSION_NAME

      USER = SY-UNAME

      KEEP = 'X'.

      ENDFORM. " BDC_OPEN_GROUP

      &----


      *& Form BDC_INSERT

      &----


      • text *

      ----


      • --> p1 Import Transaction Code

      ----


      FORM BDC_INSERT USING TCODE.

      CALL FUNCTION 'BDC_INSERT'

      EXPORTING

      TCODE = TCODE

      TABLES

      DYNPROTAB = BDCDATA

      EXCEPTIONS

      OTHERS = 0.

      ENDFORM . " BDC_INSERT

      &----


      *& Form BDC_CLOSE_GROUP

      &----


      • text *

      ----


      FORM BDC_CLOSE_GROUP.

      CALL FUNCTION 'BDC_CLOSE_GROUP'.

      ENDFORM. " BDC_CLOSE_GROUP

      &----


      *& Form BDC_PROGRAM

      &----


      • text *

      ----


      • --> p1 Import Program Identifier

      • <-- p2 Import Screen Identifier

      ----


      FORM BDC_PROGRAM USING PROGRAM DYNPRO.

      CLEAR BDCDATA.

      BDCDATA-PROGRAM = PROGRAM.

      BDCDATA-DYNPRO = DYNPRO.

      BDCDATA-DYNBEGIN = 'X'.

      APPEND BDCDATA.

      ENDFORM. " BDC_PROGRAM

      &----


      *& Form BDC_FIELDS

      &----


      • text *

      ----


      • --> p1 Import Field Name

      • --> p1 Import Field Value

      ----


      FORM BDC_FIELDS USING FNAME FVALUE.

      CHECK NOT FVALUE IS INITIAL.

      CLEAR BDCDATA.

      BDCDATA-FNAM = FNAME.

      BDCDATA-FVAL = FVALUE.

      APPEND BDCDATA.

      ENDFORM. " BDC_FIELDS

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 02:25 PM

    why not use FM HR_INFOTYPE_OPERATION instead of BDC?

    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.