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: 

Bdc for (PA40)hiring for(0000,0001,0002) working fine but employee is not getting created.

sivab4u
Active Participant
0 Kudos

Hi Friends,

I have created BDC(Call Transaction) for PA40 to maintain --> 0000, 00001, 0002. The pernr is maintained internally(Auto generated based on Number range).

so using SHDB i have recorded and done BDC, then created program, all the values are getting populated as per the bdc and the transaction is completed(it shows the generated pernr also), but record is not getting updated in pa0000 or employee is not being created..

i have checked by manual entry in pa40, on entering the data for 0000 and on click of save, bottom i am getting record created. but when i do the same i am i am not getting any sucess message.

did i miss something???

1 ACCEPTED SOLUTION

sivab4u
Active Participant
0 Kudos

Hi friends,

Now i am able to update, but when the initial screen(PA40) starts for next record the previous created pernr exists on the pernr field, so it is throwing an error. so i have do clear the pernr field for initial pa40 screen for every loop(record).

3 REPLIES 3

sivab4u
Active Participant
0 Kudos

Hi friends,

Now i am able to update, but when the initial screen(PA40) starts for next record the previous created pernr exists on the pernr field, so it is throwing an error. so i have do clear the pernr field for initial pa40 screen for every loop(record).

0 Kudos

Can you please share the code.?

sivab4u
Active Participant
0 Kudos

Please find the code...

REPORT ZHR_HIRING_DATA_UPLOAD.
types: BEGIN OF ty_hiring,
         pernr TYPE persno,
         EINDA TYPE char10,
         "begda TYPE char10,
         "endda TYPE char10,
         "massn TYPE MASSN,
         massg TYPE  char2, "massg,
         plans(8) TYPE n, "plans,
         werks TYPE char4, "PERSA,
         persg TYPE char1,"PERSG,
         persk TYPE char2,
         btrtl TYPE char4, "BTRTL,
         sachp TYPE SACHP,
         sachz type SACHZ,
         sacha type SACHA,
         zzdept type ZDEPT,
         zzsec type ZSECT,
         zzdir type ZDIR,
         zzdisp type ZDISP,
         anred type ANRDE,

         "ABKRS TYPE ABKRS,
         "ansvh TYPE ANSVH,
         "anred TYPE ANRDE,
         nachn TYPE PAD_NACHN,
         vorna TYPE PAD_VORNA,
         MIDNM TYPE PAD_MIDNM,
         name2 TYPE PAD_NAME2,
         INITS TYPE INITS,
         TITEL TYPE TITEL,
         TITL2 TYPE TITL2,
         RUFNM TYPE PAD_RUFNM,
         GBDAT TYPE char10,   "GBDAT,
         GBORT TYPE PAD_GBORT,
         GESCH TYPE GESCH,
         GBLND TYPE GBLND,
         GBDEP TYPE GBDEP,
         NATIO TYPE NATSL,
         SPRSL TYPE PAD_SPRAS,
         FAMST TYPE FAMST,
         FAMDT TYPE char10,
         ANZKD TYPE char3,
         KONFE TYPE KONFE,
         "SACHP TYPE char10,
         "SACHZ TYPE char10,
         "SACHA TYPE char10,
         zzbgv TYPE ZZBGV,
         zzcnav type ZZCNAV,
         zzcasv type ZZCASV,
   end of ty_hiring.

   data: it_hiring TYPE STANDARD TABLE OF ty_hiring,
         wa_hiring TYPE ty_hiring.
   data: it_raw TYPE TRUXS_T_TEXT_DATA,
         l_filename TYPE RLGRAP-FILENAME.
   data: wa_bdcdata TYPE bdcdata,
         it_bdcdata TYPE STANDARD TABLE OF bdcdata.
   data: it_bdcmsgcoll TYPE STANDARD TABLE OF bdcmsgcoll.

   PARAMETERS: p_path TYPE IBIPPARMS-PATH.

   at SELECTION-SCREEN on VALUE-REQUEST FOR p_path.

   call function 'F4_FILENAME'
*   EXPORTING
*     PROGRAM_NAME        = SYST-CPROG
*     DYNPRO_NUMBER       = SYST-DYNNR
*     FIELD_NAME          = ' '
    IMPORTING
      FILE_NAME           = p_path
             .
  l_filename = p_path.
   call function 'TEXT_CONVERT_XLS_TO_SAP'
     exporting
      I_FIELD_SEPERATOR          = 'X'
      I_LINE_HEADER              = 'X'
       i_tab_raw_data             = it_raw
       i_filename                 = l_filename
     tables
       i_tab_converted_data       = it_hiring
*   EXCEPTIONS
*     CONVERSION_FAILED          = 1
*     OTHERS                     = 2
             .
   if sy-subrc <> 0.
* Implement suitable error handling here
   endif.

START-OF-SELECTION.
  loop at it_hiring INTO wa_hiring.
    perform bdc_dynpro      using       'SAPMP50A'        '2000'.
    perform bdc_field       using       'BDC_CURSOR'      'T529T-MNTXT(01)'.
    perform bdc_field       using       'BDC_OKCODE'      '=PICK'.
*   perform bdc_field       using       'RP50G-PERNR'      wa_hiring-pernr.
    perform bdc_field       using       'RP50G-EINDA'      wa_hiring-einda.
    perform bdc_field       using       'RP50G-SELEC(01)' 'X'.
    perform bdc_dynpro      using       'MP000000'        '2000'.
    perform bdc_field       using       'BDC_CURSOR'      'T503T-PTEXT'.
*   perform bdc_field       using       'BDC_CURSOR'      'PSPAR-PERSK'.
    perform bdc_field       using       'BDC_OKCODE'      '=UPD'.
*   perform bdc_field       using       'P0000-BEGDA'      wa_hiring-begda.
*   perform bdc_field       using       'P0000-ENDDA'      wa_hiring-endda.
*   perform bdc_field       using       'P0000-MASSN'      wa_hiring-massn.
    perform bdc_field       using       'P0000-MASSG'      wa_hiring-massg.
    perform bdc_field       using       'PSPAR-PLANS'      wa_hiring-plans.
    perform bdc_field       using       'PSPAR-WERKS'      wa_hiring-werks.
    perform bdc_field       using       'PSPAR-PERSG'      wa_hiring-persg.
    perform bdc_field       using       'PSPAR-PERSK'      wa_hiring-persk.
    perform bdc_dynpro      using       'MP000100'        '2000'.
    perform bdc_field       using       'BDC_OKCODE'      '=FC01'.
    perform bdc_field       using       'P0001-BTRTL'      wa_hiring-btrtl.
    perform bdc_field       using       'P0001-SACHP'      wa_hiring-sachp.
    perform bdc_field       using       'P0001-SACHZ'      wa_hiring-sachz.
    perform bdc_field       using       'P0001-SACHA'      wa_hiring-sacha.
    perform bdc_field       using       'BDC_CURSOR'      'P0001-ZZDEPT'.
    perform bdc_field       using       'P0001-ZZDEPT'      wa_hiring-zzdept.
    perform bdc_dynpro      using       'MP000100'        '2000'.
    perform bdc_field       using       'BDC_OKCODE'      '=UPD'.
    perform bdc_field       using       'BDC_CURSOR'      'P0001-ZZDISP'.
    perform bdc_field       using       'P0001-ZZDEPT'      wa_hiring-zzdept.
    perform bdc_field       using       'P0001-ZZSECT'      wa_hiring-zzsec.
    perform bdc_field       using       'P0001-ZZDIR'      wa_hiring-zzdir.
    perform bdc_field       using       'P0001-ZZDISP'      wa_hiring-zzdisp.
    perform bdc_dynpro      using       'MP000200'        '2044'.
    perform bdc_field       using       'BDC_OKCODE'      '=UPD'.
    perform bdc_field       using       'P0002-ANRED'      wa_hiring-anred.
    perform bdc_field       using       'P0002-NACHN'      wa_hiring-nachn.
    perform bdc_field       using       'P0002-NAME2'      wa_hiring-name2.
    perform bdc_field       using       'P0002-VORNA'      wa_hiring-vorna.
    perform bdc_field       using       'P0002-INITS'      wa_hiring-INITS.
    perform bdc_field       using       'P0002-MIDNM'      wa_hiring-midnm.
    perform bdc_field       using       'P0002-TITEL'      wa_hiring-TITEL.
    perform bdc_field       using       'P0002-TITL2'      wa_hiring-titl2.
    perform bdc_field       using       'P0002-RUFNM'      wa_hiring-RUFNM.
    perform bdc_field       using       'P0002-GBDAT'      wa_hiring-gbdat.
    perform bdc_field       using       'P0002-GBORT'      wa_hiring-GBORT.
    perform bdc_field       using       'P0002-GESCH'      wa_hiring-GESCH.
    perform bdc_field       using       'P0002-GBLND'      wa_hiring-gblnd.
    perform bdc_field       using       'P0002-GBDEP'      wa_hiring-gbdep.
    perform bdc_field       using       'P0002-NATIO'      wa_hiring-NATIO.
    perform bdc_field       using       'P0002-SPRSL'      wa_hiring-SPRSL.
    perform bdc_field       using       'P0002-FAMST'      wa_hiring-FAMST.
    perform bdc_field       using       'P0002-FAMDT'      wa_hiring-famdt.
    perform bdc_field       using       'P0002-ANZKD'      wa_hiring-ANZKD.
    perform bdc_field       using       'P0002-KONFE'      wa_hiring-KONFE.
    perform bdc_field       using       'P0002-KONFE'      wa_hiring-KONFE.
    perform bdc_field       using       'BDC_CURSOR'      'P0002-ZZCASV'.
    perform bdc_field       using       'P0002-ZZBGV'      wa_hiring-zzbgv.
    perform bdc_field       using       'P0002-ZZCNAV'      wa_hiring-zzcnav.
    perform bdc_field       using       'P0002-ZZCASV'      wa_hiring-zzcasv.

    perform bdc_dynpro      using       'MP000400'        '2000'.
    perform bdc_field       using       'BDC_OKCODE'      '/EPRV'.
    perform bdc_field       using       'BDC_CURSOR'      'P0004-BEGDA'.
*   perform bdc_field       using       'BDC_OKCODE'      '/EEND'.
    perform bdc_dynpro      using       'MP000200'        '2044'.
    perform bdc_field       using       'BDC_OKCODE'      '/EPRV'.
    perform bdc_field       using       'BDC_CURSOR'      'P0002-BEGDA'.

     perform bdc_dynpro      using       'MP000100'        '2000'.
    perform bdc_field       using       'BDC_OKCODE'      '/EPRV'.
    perform bdc_field       using       'BDC_CURSOR'      'P0001-BEGDA'.

      perform bdc_dynpro      using       'SAPMP50A'        '2000'.
    perform bdc_field       using       'BDC_OKCODE'      '/EEND'.
    perform bdc_field       using       'BDC_CURSOR'      'RP50G-PERNR'.

    perform bdc_transaction using       'PA40'.
    ENDLOOP.
*&---------------------------------------------------------------------*
*&      Form  BDC_DYNPRO
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0227   text
*      -->P_0228   text
*----------------------------------------------------------------------*
form bdc_dynpro  using    value(p_0227)
                           value(p_0228).
CLEAR wa_bdcdata.
       wa_bdcdata-program = p_0227.
       wa_bdcdata-dynpro  = p_0228.
       wa_bdcdata-dynbegin = 'X'.
APPEND wa_bdcdata to it_bdcdata.
endform.
*&---------------------------------------------------------------------*
*&      Form  BDC_FIELD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0243   text
*      -->P_0244   text
*----------------------------------------------------------------------*
form bdc_field  using    value(p_0243)
                          value(p_0244).
CLEAR wa_bdcdata.
       wa_bdcdata-fnam = p_0243.
       wa_bdcdata-fval = p_0244.
APPEND wa_bdcdata to it_bdcdata.
endform.
*&---------------------------------------------------------------------*
*&      Form  BDC_TRANSACTION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0518   text
*----------------------------------------------------------------------*
form bdc_transaction  using    value(p_0518).
  call TRANSACTION p_0518 USING it_bdcdata MODE 'E' MESSAGES INTO it_bdcmsgcoll.
endform.


Thank you guys the issue is resolved, by simple thought, i just made the pernr of char8 and was passing blank field in excel file this solved the issue.

thank you all for your support.