Application Development and Automation 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: 
Read only

load

Former Member
0 Likes
556

hi folks,

I have a sequential file to load data into SAP. In this process, I have to load the data to PA0000 and PA0001 infotypes and then the positions on 1007 infotype, while dong this, CALL TRANSACTION 'PA30' the program is throwing an error mssg saying that 'call transaction failed' and personnel number does not exist and select the hiring action.

while the data is reading from the sequential file into the bdc_tab in the right format.

Can anyone put some light onto this?

Thanks

Vinu.

4 REPLIES 4
Read only

Former Member
0 Likes
502

Can you please paste a piece of code...it's easier to help when you can read it -;)

Greetings,

Blag.

Read only

Former Member
0 Likes
502

Hi,

In order to create a new record U need to go thru

PA40.

Regards,

GSR.

Read only

Former Member
0 Likes
502

Hi Vinu,

I guess the data is not loaded to PA0000 & PA0001 & during the call transaction 'PA30',it is checking for the Personnel number which was supposed to get created in those tables.

You can use statement

WAIT UP TO time SECONDS. or soime thing like that before doing the call transaction PA30.

Read only

0 Likes
502

I know that,

here is the piece of code

TABLES: pa0171, p0171, pa0002, zmetzpos, pa0001.

DATA: upd00(1) TYPE c,

upd01(1) TYPE c.

DATA message_text(254) TYPE c.

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

  • parameters

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

SELECTION-SCREEN BEGIN OF BLOCK ch1 WITH FRAME.

PARAMETERS: zbegda LIKE p0171-begda DEFAULT sy-datum,

zendda LIKE p0171-endda DEFAULT '99991231',

filein(60) DEFAULT '/interfacep/inbound/one.txt' LOWER CASE,

filestat(60) DEFAULT '/interfacep/outbound/rs.txt'

LOWER CASE,

fileout(60) DEFAULT '/interfacep/outbound/errors.txt

LOWER CASE,

  • DV1K902244

  • s_mode TYPE c DEFAULT 'N',

  • rest AS CHECKBOX.

s_mode TYPE c DEFAULT 'N'.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETER: rest AS CHECKBOX.

SELECTION-SCREEN COMMENT 5(70) text-001.

SELECTION-SCREEN END OF LINE.

  • DV1K902244

SELECTION-SCREEN END OF BLOCK ch1.

DATA:zvalid LIKE p0171-begda.

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

  • internal tables

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

DATA: BEGIN OF itab_in OCCURS 1,

pernr(8) TYPE c,

filler1(56) TYPE c,

sachz(3) TYPE c,

END OF itab_in.

DATA: BEGIN OF hold_tab OCCURS 1,

pernr(8) TYPE c,

filler1(56) TYPE c,

sachz(3) TYPE c,

END OF hold_tab.

DATA:work_pernr(8) TYPE c.

*format of the bdc input file, with extra field for pernr*

DATA: BEGIN OF itab OCCURS 1,

begda LIKE p0171-begda,

endda LIKE p0171-endda,

offic LIKE p0171-offic,

pernr LIKE p0002-pernr,

END OF itab.

DATA: BEGIN OF messtab OCCURS 10.

INCLUDE STRUCTURE bdcmsgcoll.

DATA: END OF messtab.

DATA: bdc_tab LIKE bdcdata OCCURS 0 WITH HEADER LINE.

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

  • variables

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

DATA: zpernr LIKE p0002-pernr,

bisflag(1) TYPE c VALUE 'N'.

DATA: format_begda LIKE p0171-begda.

DATA: format_valid LIKE p0171-begda.

DATA: format_endda LIKE p0171-begda.

DATA: eofflag(1) TYPE n.

DATA: record_read(9) TYPE n.

DATA: ssn_error TYPE i.

DATA: record_created(9) TYPE n.

DATA: record_error(9) TYPE n.

DATA: officer_count TYPE i.

DATA: officer_fail TYPE i.

DATA: zreturn_code LIKE sy-subrc.

*initialization*******************************************************

INITIALIZATION.

ssn_error = 0.

record_read = 0.

record_error = 0.

zreturn_code = 0.

officer_count = 0.

*start-of-selection***************************************************

START-OF-SELECTION.

*formating the date to be MMDDYYYY instead of YYYYMMDD*

zvalid = zbegda - 1.

CONCATENATE zvalid4(2) zvalid6(2) zvalid(4) INTO format_valid.

CONCATENATE zbegda4(2) zbegda6(2) zbegda(4) INTO format_begda.

CONCATENATE zendda4(2) zendda6(2) zendda(4) INTO format_endda.

*open the files for input and output*

IF rest = 'X'.

OPEN DATASET fileout FOR APPENDING IN TEXT MODE.

IF sy-subrc NE 0.

WRITE: /'Could not open error output file.'.

EXIT.

ENDIF.

ELSE.

OPEN DATASET fileout FOR OUTPUT IN TEXT MODE.

IF sy-subrc NE 0.

WRITE: /'Could not open error output file.'.

EXIT.

ENDIF.

ENDIF.

OPEN DATASET filein FOR INPUT IN TEXT MODE.

IF sy-subrc NE 0.

WRITE: /'Could not open input file.'.

EXIT.

ENDIF.

IF rest = 'X'.

OPEN DATASET filestat FOR INPUT IN TEXT MODE.

IF sy-subrc NE 0.

WRITE: /'Could not open input file.'.

EXIT.

ENDIF.

WHILE eofflag = 0.

work_pernr = hold_tab-pernr.

READ DATASET filestat INTO hold_tab.

eofflag = sy-subrc.

ENDWHILE.

CLOSE DATASET filestat.

WHILE work_pernr NE itab_in-pernr.

READ DATASET filein INTO itab_in.

ENDWHILE.

OPEN DATASET filestat FOR APPENDING IN TEXT MODE.

IF sy-subrc NE 0.

WRITE: /'Could not open stat file. '.

EXIT.

ENDIF.

ELSE.

OPEN DATASET filestat FOR OUTPUT IN TEXT MODE.

IF sy-subrc NE 0.

WRITE:/ 'Could not open stat file '.

EXIT.

ENDIF.

ENDIF.

*processing the input file*

DO.

READ DATASET filein INTO itab_in.

IF sy-subrc NE 0.

EXIT.

ENDIF.

REFRESH itab.

CLEAR itab.

REFRESH messtab.

CLEAR messtab.

*TRANSFERRING DATA TO ITAB WITH SAP DEFINED FIELDS FOR PROCESSING*

*count of how many records the program reads from the file*

record_read = record_read + 1.

*processing to look-up ssn and get the appropriate pernr*

    • a pernr of '00000000' means that there is not a valid pernr for the

    • given ssn, therefore the return code will = 4**

itab-pernr = itab_in-pernr.

itab-begda = format_begda.

SELECT SINGLE pdposition sacha INTO

(zmetzpos-pdposition, zmetzpos-sacha)

FROM zmetzpos

WHERE pernr = itab-pernr.

IF sy-subrc NE 0.

CLEAR zmetzpos-pdposition.

CLEAR zmetzpos-sacha.

ENDIF.

CLEAR upd00.

CLEAR upd01.

*filling the bdc_tab for processing*

PERFORM fill_bdc_tab.

HERE...... THE DATA IS UPDATED IN THE INTERNAL TABLE

'BDC_TAB' AND THE PERSONNEL NUMBER, BEGDA AND MASSN ARE STORED.

*calling the PA30 transaction to process the records in the bdc_tab*

HERE THE TRANSACTION IS FAILING,

CALL TRANSACTION 'PA30'

USING bdc_tab

MODE s_mode

UPDATE 'S'

MESSAGES INTO messtab.

IF sy-subrc NE 0.

TRANSFER itab_in TO filestat.

TRANSFER itab_in TO fileout.

record_error = record_error + 1.

PERFORM write_errors.

  • Add to batch session

IF bisflag = 'N'.

bisflag = 'Y'.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

client = sy-mandt

group = 'CONVPSN'

keep = 'X' "Retention flag

user = sy-uname "Batch input user name

EXCEPTIONS

client_invalid = 01

destination_invalid = 02

group_invalid = 03

holddate_invalid = 04

internal_error = 05

queue_error = 06

running = 07

user_invalid = 08.

ENDIF.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

tcode = 'PA30'

TABLES

dynprotab = bdc_tab

EXCEPTIONS

internal_error = 01

not_open = 02

queue_error = 03

tcode_invalid = 04.

ELSE.

upd00 = 'y'.

record_created = record_created + 1.

TRANSFER itab_in TO filestat.

ENDIF.

  • if upd00 = 'y'.

  • perform delimit.

  • endif.

ENDDO.

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

  • update records for officers, read the file with ssn's of officers and*

  • update the officer flag on IT0171 to 'X'. *

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

  • perform update_officers.

*writing the stats of the program to the screen and to the stats file*

  • perform write_to_file.

WRITE:/.

WRITE:/ 'Total records read ', record_read.

WRITE:/ 'Total error records that went to batch ', record_error.

WRITE:/ 'Total records created in SAP ', record_created.

*close all files that were open for processing*

CLOSE DATASET fileout.

CLOSE DATASET filein.

CLOSE DATASET filestat.

  • close dataset filestat.

  • close dataset fileoffi.

  • close dataset filemess.

IF bisflag = 'Y'.

CALL FUNCTION 'BDC_CLOSE_GROUP'

EXCEPTIONS

not_open = 01

queue_error = 02.

ENDIF.

&----


*& Form INFOTYPE1

&----


  • text

----


FORM infotype1.

PERFORM fill_bdc_tab2.

*calling the PA30 transaction to process the records in the bdc_tab*

CALL TRANSACTION 'PA30'

USING bdc_tab

MODE s_mode

UPDATE 'S'

MESSAGES INTO messtab.

IF sy-subrc NE 0.

TRANSFER itab_in TO filestat.

TRANSFER itab_in TO fileout.

record_error = record_error + 1.

PERFORM write_errors.

  • Add to batch session

IF bisflag = 'N'.

bisflag = 'Y'.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

client = sy-mandt

group = 'CONVPSN'

keep = 'X' "Retention flag

user = sy-uname "Batch input user name

EXCEPTIONS

client_invalid = 01

destination_invalid = 02

group_invalid = 03

holddate_invalid = 04

internal_error = 05

queue_error = 06

running = 07

user_invalid = 08.

ENDIF.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

tcode = 'PA30'

TABLES

dynprotab = bdc_tab

EXCEPTIONS

internal_error = 01

not_open = 02

queue_error = 03

tcode_invalid = 04.

ELSE.

upd01 = 'y'.

record_created = record_created + 1.

TRANSFER itab_in TO filestat.

ENDIF.

ENDFORM. "INFOTYPE1

&----


*& Form DELIMIT

&----


  • text

----


FORM delimit.

PERFORM fill_bdc_tab3.

*calling the PA30 transaction to process the records in the bdc_tab*

CALL TRANSACTION 'PP01'

USING bdc_tab

MODE s_mode

UPDATE 'S'

MESSAGES INTO messtab.

IF sy-subrc NE 0.

TRANSFER itab_in TO filestat.

TRANSFER itab_in TO fileout.

record_error = record_error + 1.

PERFORM write_errors.

  • Add to batch session

IF bisflag = 'N'.

bisflag = 'Y'.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

client = sy-mandt

group = 'CONVPSN'

keep = 'X' "Retention flag

user = sy-uname "Batch input user name

EXCEPTIONS

client_invalid = 01

destination_invalid = 02

group_invalid = 03

holddate_invalid = 04

internal_error = 05

queue_error = 06

running = 07

user_invalid = 08.

ENDIF.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

tcode = 'PA30'

TABLES

dynprotab = bdc_tab

EXCEPTIONS

internal_error = 01

not_open = 02

queue_error = 03

tcode_invalid = 04.

ELSE.

record_created = record_created + 1.

TRANSFER itab_in TO filestat.

ENDIF.

ENDFORM. "DELIMIT

&----


*& Form FILL_BDC_TAB

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fill_bdc_tab.

*make sure bdc_tab is empty for the next entry*

REFRESH bdc_tab.

PERFORM populate_bdc_tab USING:

'1' 'SAPMP50A' '1000', "program name and screen number

' ' 'BDC_OKCODE' '/00',

' ' 'BDC_CURSOR' 'RP50G-CHOIC',

' ' 'RP50G-PERNR' itab-pernr, "personnel number

' ' 'RP50G-CHOIC' '0',

' ' 'RP50G-TIMR6' 'X',

'1' 'SAPMP50A' '1000',

' ' 'BDC_OKCODE' 'INS',

  • ' ' 'BDC_CURSOR' ITAB-PERNR,

'1' 'MP000000' '2000', "program and screen for the IT171

*' ' 'BDC_OKCODE' 'UPD',

  • ' ' 'BDC_CURSOR' ITAB-DOCI1,

' ' 'P0000-BEGDA' itab-begda, "begin date

' ' 'P0000-MASSN' 'CP', "event type

' ' 'PSPAR-PLANS' zmetzpos-pdposition, "position

  • ' ' 'P0171-OFFIC' itab-offic, "company officer indicator

  • ' ' 'P0171-DOCN1' itab-docn1, "doctor name

  • ' ' 'P0171-DOCI1' itab-doci1, "doctor id number

  • ' ' 'P0171-HICMP' itab-hicmp, "highly compensated employee ind.

' ' 'BDC_OKCODE' '/11', "save

'1' 'MP000100' '2010', "program and screen for the IT171

*' ' 'BDC_OKCODE' 'UPD',

  • ' ' 'BDC_CURSOR' ITAB-DOCI1,

' ' 'P0001-BEGDA' itab-begda, "begin date

' ' 'P0001-SACHA' zmetzpos-sacha, "payroll admin

' ' 'P0001-SACHZ' itab_in-sachz, "time

  • ' ' 'P0171-OFFIC' itab-offic, "company officer indicator

  • ' ' 'P0171-DOCN1' itab-docn1, "doctor name

  • ' ' 'P0171-DOCI1' itab-doci1, "doctor id number

  • ' ' 'P0171-HICMP' itab-hicmp, "highly compensated employee ind.

' ' 'BDC_OKCODE' '/11', "save

' ' 'BDC_OKCODE' '/11'. "save

ENDFORM. " FILL_BDC_TAB

&----


*& Form FILL_BDC_TAB3

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fill_bdc_tab3.

*make sure bdc_tab is empty for the next entry*

REFRESH bdc_tab.

PERFORM populate_bdc_tab USING:

'1' 'SAPMH5A0' '5000', "program name and screen number

' ' 'PPHDR-OTYPE' 'S ', "object type

' ' 'BDC_OKCODE' '/00',

' ' 'PM0D1-SEARK' zmetzpos-pdposition, "position

' ' 'PPHDR-BEGDA' format_begda, "validity begin date

' ' 'PPHDR-ENDDA' format_endda, "validity end date

' ' 'BDC_OKCODE' '/00',

' ' 'BDC_OKCODE' 'CUTI',

'1' 'SAPMH5A0' '5000', "program name and screen number

' ' 'PM0D1-PPSEL(6)' 'X', "click vacancy

' ' 'PM0D1-PPACTIV(6)' 'X', "click active

' ' 'BDC_OKCODE' 'CUTI',

  • ' ' 'BDC_CURSOR' ITAB-PERNR,

'1' 'MP100700' '2000', "program and screen for the IT171

*' ' 'BDC_OKCODE' 'UPD',

  • ' ' 'BDC_CURSOR' ITAB-DOCI1,

' ' 'P1007-ENDDA' format_valid, "end validity date

' ' 'PPHDR-HISTO' 'X', "click historical records

  • ' ' 'P0171-OFFIC' itab-offic, "company officer indicator

  • ' ' 'P0171-DOCN1' itab-docn1, "doctor name

  • ' ' 'P0171-DOCI1' itab-doci1, "doctor id number

  • ' ' 'P0171-HICMP' itab-hicmp, "highly compensated employee ind.

' ' 'BDC_OKCODE' 'CUTI'. "save

ENDFORM. " FILL_BDC_TAB

&----


*& Form FILL_BDC_TAB2

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fill_bdc_tab2.

*make sure bdc_tab is empty for the next entry*

REFRESH bdc_tab.

PERFORM populate_bdc_tab USING:

'1' 'SAPMP50A' '1000', "program name and screen number

' ' 'BDC_OKCODE' '/00',

' ' 'BDC_CURSOR' 'RP50G-CHOIC',

' ' 'RP50G-PERNR' itab-pernr, "personnel number

' ' 'RP50G-CHOIC' '1',

' ' 'RP50G-TIMR6' 'X',

'1' 'SAPMP50A' '1000',

' ' 'BDC_OKCODE' 'INS',

  • ' ' 'BDC_CURSOR' ITAB-PERNR,

'1' 'MP000100' '2010', "program and screen for the IT171

*' ' 'BDC_OKCODE' 'UPD',

  • ' ' 'BDC_CURSOR' ITAB-DOCI1,

' ' 'P0001-BEGDA' itab-begda, "begin date

' ' 'P0001-SACHA' zmetzpos-sacha, "payroll admin

' ' 'P0001-SACHZ' itab_in-sachz, "time

  • ' ' 'P0171-OFFIC' itab-offic, "company officer indicator

  • ' ' 'P0171-DOCN1' itab-docn1, "doctor name

  • ' ' 'P0171-DOCI1' itab-doci1, "doctor id number

  • ' ' 'P0171-HICMP' itab-hicmp, "highly compensated employee ind.

' ' 'BDC_OKCODE' '/11'. "save

ENDFORM. " FILL_BDC_TAB

&----


*& Form POPULATE_BDC_TAB

&----


  • text

----


  • -->P_0393 text *

  • -->P_0394 text *

  • -->P_0395 text *

----


FORM populate_bdc_tab USING flag var1 var2.

CLEAR bdc_tab.

IF flag = '1'.

bdc_tab-program = var1.

bdc_tab-dynpro = var2.

bdc_tab-dynbegin = 'X'.

ELSE.

bdc_tab-fnam = var1.

bdc_tab-fval = var2.

ENDIF.

APPEND bdc_tab.

ENDFORM. " POPULATE_BDC_TAB

&----


*& Form WRITE_ERRORS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM write_errors.

CALL FUNCTION 'Z_REPORT'

EXPORTING

display_to_screen = 'Y'

message_number = '000'

variable_1 = 'Call transaction failed '

variable_2 = itab-pernr

variable_3 = ''

variable_4 = ''

message_id = 'ZZ'

EXCEPTIONS

cant_open_file = 1

OTHERS = 2.

WRITE: / 'Call Transaction failed ', itab-pernr.

LOOP AT messtab.

CALL FUNCTION 'Z_REPORT'

EXPORTING

display_to_screen = 'Y'

  • RUN_IN_BATCH = SY-BATCH

message_number = messtab-msgnr

variable_1 = messtab-msgv1

variable_2 = messtab-msgv2

variable_3 = messtab-msgv3

variable_4 = messtab-msgv4

message_id = messtab-msgid

EXCEPTIONS

cant_open_file = 1

OTHERS = 2.

CALL FUNCTION 'Z_MESSAGE_TEXT_BUILD'

EXPORTING

msgid = messtab-msgid

msgnr = messtab-msgnr

msgv1 = messtab-msgv1

msgv2 = messtab-msgv2

msgv3 = messtab-msgv3

msgv4 = messtab-msgv4

IMPORTING

message_text_output = message_text

EXCEPTIONS

message_not_found = 01.

WRITE: / message_text.

ENDLOOP.

CALL FUNCTION 'Z_REPORT'

EXPORTING

display_to_screen = 'Y'

message_number = '000'

variable_1 = ' '

variable_2 = ''

variable_3 = ''

variable_4 = ''

message_id = 'ZZ'

EXCEPTIONS

cant_open_file = 1

OTHERS = 2.

WRITE: /.

ENDFORM. " WRITE_ERRORS

Note: Also, the objects have to be loaded into HRP1000 has thing something to do with it?

Let me know..

thanks.

Vinu