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

file structure

Former Member
0 Likes
2,629

hi folks,

I am trying to read data from an external flat file into the internal table using Batch input.

the flat file is in this format

number - 90015910

datein - 2/16/2006

enddate - 12/31/9999

Action type - AR

Reason of action - blank

po number - 02181205

the data was not reading into the internal table

DATA: BEGIN OF A,

pernr(8) TYPE c,

begda(8) TYPE c,

endda(8) TYPE c,

massn(2) TYPE c,

massg(2) TYPE c,

plans(8) TYPE c,

End of A.

So I used tab_line to split the data correctly into the fields

DATA: tb_line(81) type c.

DATA: tb_tab type x value '09'.

READ DATASET filein INTO tb_line.

IF SY-SUBRC NE 0.

EXIT.

ENDIF.

split tb_line at tb_tab into

A-pernr A-begda

A-endda A-massn

A-massg A-plans.

My problem is only the first field 'A-pernr ' is getting the value from the flat file while the other fields are not getting populated.

I hope I have given the length of the tb_line right taking into account the delimit spaces.

Can anyone advise here. why is it so?

Thanks

Vinu

29 REPLIES 29
Read only

Former Member
0 Likes
2,580

Dates should be 10 characters long, check that once...

Read only

0 Likes
2,580

try using a comma delimited file. I find it much easier and much more fool proof.

REgards,

Rich Heilman

Read only

0 Likes
2,580

You should define you IT like this:


DATA: BEGIN OF A,
pernr(8) TYPE c,
begda(10) TYPE c,
endda(10) TYPE c,
massn(2) TYPE c,
massg(2) TYPE c,
plans(8) TYPE c,
End of A.

Greetings,

Blag.

Read only

0 Likes
2,580

I changed the date field to 10 characters and the file format is in the form

90014060#2/16/2006#12/31/9999#CP##218120 and I am concerned about reading the

pernr = 90014060

begda = 2/16/2006

pno = 218120 from the flat file

I took of the tb_line and that declaration just by plain transferring the flat file

pno = ##218120 ( I know the pno is 8 chars long)

How can I adjust the value here and if the value is less than 8 like in this case the two ## signs should be avoided.

Thanks for help.

Vinu

Read only

0 Likes
2,580

Hi Vinu,

Use FM CONVERSION_EXIT_ALPHA_INPUT before passing it to the file.It will append 0's in front of the field.

Read only

0 Likes
2,580

Hi Phani,

Is there a way that I can do some changes there itself instead of using the FM.

thanks

Vinu.

Read only

0 Likes
2,580

Hi,

if it is a char field , you can use replace command

REPLACE ALL OCCURRENCES OF '#' IN ty_itab WITH '0'.

Laxman

Read only

0 Likes
2,580

Hi Vinu,

You input file looks like Tabdelimited file :

May be define your internal table :

DATA: BEGIN OF A OCCURS 0,

pernr(8) TYPE c,

C1(1),

begda(10) TYPE c,

C2(1),

endda(10) TYPE c,

C3(1),

massn(2) TYPE c,

C4(1),

massg(2) TYPE c,

C5(1),

plans(8) TYPE c,

End of A.

and One of the field value is not filling which is causing extra #..

Lanka

Read only

0 Likes
2,580

Hi,

you have to use some statement or the other.So better call the FM.I suggest you ,its the best way.You need to pass only one field..you can pass the same field & get output also in the same field.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = V_TEXT

IMPORTING

OUTPUT = V_TEXT

EXCEPTIONS

OTHERS = 1.

Read only

0 Likes
2,580

hi guys,

I think you did not get my problem, the last field 'pno' is picking up an extra value, I used the flat file in the .csv format, instead of # I am getting '0'. the value for the last field should take '02181205' and now it is taking '002181205'

I think there is some spacing problem from the flat file and I need to fix this.

I hope you could help me here.

Thanks

Vinu

Read only

0 Likes
2,580

Hi Vinu,

You have to use logic for fields for which you want leading zeros & for those you dont.

for leading zeros you can use the FM i gave.

Foe leading spaces use concatenate statement.

Read only

Former Member
0 Likes
2,580

Hi Vinu,

all date field should be 10 chars, change that and see..

regards

vijay

Read only

Former Member
0 Likes
2,580

pls check in debugging that tb_line is getting populated with all the values at the line - "READ DATASET filein INTO tb_line."(check how the values are populated)

Also is the delimiter a horizontal tab ?

how did you arrive at length of 81 for tb_line?

Thanks,

Renjith

Read only

Former Member
0 Likes
2,580

Hi Vinu,

Define your internal table as below..CHECK THE BOLD LETTERS.

DATA: BEGIN OF<b> A OCCURS 0</b>,

pernr(8) TYPE c,

begda(8) TYPE c,

endda(8) TYPE c,

massn(2) TYPE c,

massg(2) TYPE c,

plans(8) TYPE c,

End of A.

Read only

0 Likes
2,580

Hi Vinu,

DATA: BEGIN OF<b> A OCCURS 0</b>,

pernr(8) TYPE c,

<b>begda(10) TYPE c,

endda(10) TYPE c,</b>

massn(2) TYPE c,

massg(2) TYPE c,

plans(8) TYPE c,

End of A.

you missed two things, one is occurs 0, and other is date should 10 chars.

Regards

Vijay

Regards

vijay

Read only

Former Member
0 Likes
2,580

hi folks,

Here is the scenario and can anyone help me to correct this structure?

the file structure goes like this...

number - 90015910

datein - 2/16/2006

enddate - 12/31/9999

Action type - AR

Reason of action - blank

po number - 02181205

whereas I am receiving the data in the table as

90014060,2/16/2006,12/31/9999,AR,,218120

A-number - 90015910

A-datein -,2/16/2006

A-enddate -,12/31/999

A-Action type -9,

A-reason of action - AR

A-po number - ,,218120

Thanks

Vinu

Read only

0 Likes
2,580

Hi Vinu,

Check the length of the fields defined.Or can you give me the whole code,so that i can check & let u know.

Read only

0 Likes
2,580

REPORT za0001 MESSAGE-ID ZMSG.

TABLES: pa0000, 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 p0000-begda DEFAULT sy-datum,

zendda LIKE p0000-endda DEFAULT '99991231',

this file is uploaded on the ftp (application server)

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

filestat(60) DEFAULT '/interfacep/outbound/restart.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 'A'.

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 p0000-begda.

*DATA: tb_line(81) type c.

*DATA: tb_tab type x value '09'.

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

  • internal tables

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

DATA: BEGIN OF itab_in occurs 0,

pernr(8) TYPE c,

begda(10) TYPE c,

endda(10) TYPE c,

massn(2) TYPE c,

massg(2) TYPE c,

plans(8) TYPE c,

*pernr(8) TYPE c,

*filler1(56) TYPE c,

*sachz(3) TYPE c,

END OF itab_in.

DATA: BEGIN OF hold_tab,

pernr(8) TYPE c,

begda(8) TYPE c,

endda(8) TYPE c,

massn(2) TYPE c,

massg(2) TYPE c,

plans(8) TYPE c,

*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 p0000-begda,

endda LIKE p0000-endda,

plans LIKE pspar-plans,

*offic LIKE p0171-offic,

pernr LIKE p0000-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 p0000-begda.

DATA: format_valid LIKE p0000-begda.

DATA: format_endda LIKE p0000-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.'.

  • MESSAGE E000.

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.

  • clear tb_line.

  • clear tb_tab.

WHILE eofflag = 0.

work_pernr = hold_tab-pernr.

READ DATASET filestat INTO hold_tab.

  • work_pernr = hold_tab-pernr.

  • READ DATASET filestat INTO tb_line.

  • IF SY-SUBRC NE 0.

  • EXIT.

  • ENDIF.

  • split tb_line at tb_tab into hold_tab-pernr hold_tab-begda

  • hold_tab-endda hold_tab-massn

  • hold_tab-massg hold_tab-plans.

eofflag = sy-subrc.

ENDWHILE.

CLOSE DATASET filestat.

  • clear tb_line.

  • clear tb_tab.

WHILE work_pernr NE itab_in-pernr.

READ DATASET filein INTO itab_in.

  • READ DATASET filein INTO tb_line.

  • IF SY-SUBRC NE 0.

  • EXIT.

  • ENDIF.

  • split tb_line at tb_tab into itab_in-pernr itab_in-begda

  • itab_in-endda itab_in-massn

  • itab_in-massg itab_in-plans.

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.

  • clear tb_line.

  • clear tb_tab.

READ DATASET filein INTO itab_in.

IF sy-subrc NE 0.

EXIT.

ENDIF.

.

  • READ DATASET filein INTO tb_line.

  • IF SY-SUBRC NE 0.

  • EXIT.

  • ENDIF.

  • split tb_line at tb_tab into itab_in-pernr itab_in-begda

  • itab_in-endda itab_in-massn

  • itab_in-massg itab_in-plans.

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.

itab-begda = format_begda.

itab-plans = itab_in-plans.

  • itab-plans = v_plans.

  • SELECT SINGLE pdposition INTO

  • (zmetzpos-pdposition)

  • 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.

*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.

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

' ' 'P0000-MASSG' ' ', "reason for action type

' ' 'PSPAR-PLANS' itab-plans, "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' itab-plans, "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

Read only

0 Likes
2,581

Let me explain what I am trying to do in the program, loading the pernr,begda and positions into the PA0000 and PA0001 and then delimiting the Vacancy type in IT1007 infotype.

This data comes from the external file...that I was talking about.

Thanks

Phani.

Read only

0 Likes
2,581

I'm still saying that a comma delimted file would be better. All you need to do is READ dataset, then use "SPLIT itab at ','" to put the values in the appropriate fields. The system will handle skipping over the commas. I think that you are really making it harder than it is.

Regards,

Rich Heilman

Read only

0 Likes
2,581

hi Rich,

DATA: tb_line(81) type c.

DATA: tb_tab type x value '09'.

The flat file is on ftp server....

filein(60) DEFAULT '/interfacep/inbound/one.csv'

in the format :

I tried that too, here you go..

READ DATASET filein INTO tb_line.

The data in the tb_line is in this format

90014060,2/16/2006,12/31/9999,CP,,2181205#

The extra '#' is coming in

IF SY-SUBRC NE 0.

EXIT.

ENDIF.

split tb_line at tb_tab into itab_in-pernr

itab_in-begda itab_in-endda itab_in-massn

itab_in-massg itab_in-plans.

The result is only itab_in-pernr is taking the value and the other values are not getting updated in to the fields.

This is the scenario . Can you help me out here?

Thanks in advance.

Vinu

Read only

0 Likes
2,581

What is the value of <b> tb_tab</b>. Is it a <b>comma(,)?</b>

Regards,

Rich Heilman

Read only

0 Likes
2,581

Try this.

split tb_line <b>at ','</b> into itab_in-pernr 
                          itab_in-begda 
                          itab_in-endda 
                          itab_in-massn
                          itab_in-massg 
                          itab_in-plans.

Regards,

RIch Heilman

Read only

0 Likes
2,581

Hi Vinu

If you use the comma as separator element, why are you splitting the file using TAB sign.

If the data are this format:

90014060,2/16/2006,12/31/9999,CP,,2181205#

Your code shoul be:

READ DATASET filein INTO tb_line.

IF SY-SUBRC NE 0.

EXIT.

ENDIF.

split tb_line at ',' into itab_in-pernr

itab_in-begda itab_in-endda itab_in-massn

itab_in-massg itab_in-plans.

The sign # means the end of the record

Max

Read only

0 Likes
2,581

Thanks Rich, it worked but

itab_in-plans = 2181205# I know it is an 8 char field but the value 7 hence the '#' sign is getting in,

how to eliminate that?

Vinu

Read only

0 Likes
2,581

If you have converted your file to a comma delimted text file correctly, you should not have and #. If you have a .txt file, remove all space after the record. This should get rid of the #. If not, you can shave it off in your program. Something like this, but I guess you have to make sure that the '#' is even there. I use comma delimted files all the time, I never have "#" in my source file. I have the data in excel, then I save it as a comma delimted file or .csv file. Then, I usually open that file using notepad and save it as a .txt file.

report zrich_0003 .

data: itab_in-plans(8) type c value '2181205#'.

shift itab_in-plans right by 1 places.
shift itab_in-plans left by 1 places.


write:/ itab_in-plans.

Regards,

Rich Heilman

Read only

0 Likes
2,581

Hi

Try to use TEXT MODE option when you open your file:

OPEN DATASET <FILE> FOR IN TEXT MODE ENCODING DEFAULT.

max

Read only

0 Likes
2,581

Thanks a lot for your hlep guys and i have awarded points accordingly.

Vinu

Read only

Former Member
0 Likes
2,580

Hi Vinu,

data: begin of itab occurs 0,
      pernr(8) TYPE c,
       begda(10) TYPE c,
      endda(10) TYPE c,
      massn(2) TYPE c,
      massg(2) TYPE c,
       plans(8) TYPE c,
     end of itab.
"save the fiel as tab delimited file, and then upload "the data and check it.
"create the file in excel and save it as tab delimited "file and upload it.
CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
         FILENAME                = FILENAME
         HAS_FIELD_SEPARATOR     = 'X'
    TABLES
         DATA_TAB                = ITAB
    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.

Regards

vijay