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

regarding splitting

Former Member
0 Likes
539

hi,

This program is for splitting the data in the application server and loading it in the database...but only the accno is getting copied into the database other fields r blank..

please help me..

DATA: STR(10000).

constants: con_tab(1) type c value '#'.

data: begin of itab1 occurs 0,

ZCUSTID LIKE ZCUST_MASTER2-ZCUSTID,

ZCUSTNAME LIKE ZCUST_MASTER2-ZCUSTNAME,

ZADDR LIKE ZCUST_MASTER2-ZADDR,

ZCITY LIKE ZCUST_MASTER2-ZCITY,

ZSTATE LIKE ZCUST_MASTER2-ZSTATE,

ZCOUNTRY LIKE ZCUST_MASTER2-ZCOUNTRY,

ZPHONE LIKE ZCUST_MASTER2-ZPHONE,

ZEMAIL LIKE ZCUST_MASTER2-ZEMAIL,

ZFAX LIKE ZCUST_MASTER2-ZFAX,

ZSTAT LIKE ZCUST_MASTER2-ZSTAT,

end of itab1.

data : sr_dir TYPE dxfields-longpath VALUE 'E:\usr\sap\ECC\SYS\gen\dbg'.

data: FILE1 LIKE DXFIELDS-LONGPATH.

CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'

EXPORTING

I_LOCATION_FLAG = 'A'

I_SERVER = ''

I_PATH = sr_dir

FILEMASK = '.'

FILEOPERATION = 'R'

IMPORTING

  • O_LOCATION_FLAG =

  • O_SERVER =

O_PATH = FILE1

  • ABEND_FLAG =

  • EXCEPTIONS

  • RFC_ERROR = 1

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

OPEN DATASET FILE1 FOR INPUT IN TEXT MODE ENCODING DEFAULT.

do.

READ DATASET FILE1 INTO str.

if sy-subrc ne 0.

EXIT.

else.

*split str at '#' into itab1-zcustid itab1-zcustname itab1-zaddr itab1-zcity itab1-zstate itab1-zcountry itab1-zphone itab1-zemail itab1-zfax itab1-zstat.

split STR at con_tab into itab1-zcustid str.

split STR at con_tab into itab1-zcustname str.

split STR at con_tab into itab1-zaddr str.

split STR at con_tab into itab1-zcity str.

split STR at con_tab into itab1-zstate str.

split STR at con_tab into itab1-zcountry str.

split STR at con_tab into itab1-zphone str.

split STR at con_tab into itab1-zemail str.

split STR at con_tab into itab1-zfax str.

split STR at con_tab into itab1-zstat str.

append itab1.

insert zcust_master7 from itab1.

endif.

enddo.

CLOSE DATASET FILE1.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
510

Hi,

Use SPLIT as follows:

SPLIT str AT con_tab INTO itab1-zcustid itab1-zcustname itab1-zaddr itab1-zcity itab1-zstate itab1-zcountry

itab1-zphone itab1-zemail itab1-zfax itab1-zstat .

4 REPLIES 4
Read only

Former Member
0 Likes
511

Hi,

Use SPLIT as follows:

SPLIT str AT con_tab INTO itab1-zcustid itab1-zcustname itab1-zaddr itab1-zcity itab1-zstate itab1-zcountry

itab1-zphone itab1-zemail itab1-zfax itab1-zstat .

Read only

0 Likes
510

HI..

Thanks for the reply..i got the output

Read only

Former Member
0 Likes
510

split STR at con_tab into itab1-zcustid str itab1-zcustname itab1-zaddr itab1-zcity itab1-zstate itab1-zcountry itab1-zphone itab1-zemail itab1-zfax itab1-zstat.

OR

SPLIT str AT con_tab INTO TABLE itab1.

Put above code in the Else condition removinf urs.

awrd points if useful

Bhupal

Read only

former_member402443
Contributor
0 Likes
510

Hi Saipriya,

Check this code. I have made little bit changes to it.

For using the Split statement all the fields should be of character type.

DATA: STR(10000).

constants: con_tab(1) type c value '#'.

data: begin of itab1 occurs 0,

ZCUSTID LIKE ZCUST_MASTER2-ZCUSTID,

ZCUSTNAME LIKE ZCUST_MASTER2-ZCUSTNAME,

ZADDR LIKE ZCUST_MASTER2-ZADDR,

ZCITY LIKE ZCUST_MASTER2-ZCITY,

ZSTATE LIKE ZCUST_MASTER2-ZSTATE,

ZCOUNTRY LIKE ZCUST_MASTER2-ZCOUNTRY,

ZPHONE LIKE ZCUST_MASTER2-ZPHONE,

ZEMAIL LIKE ZCUST_MASTER2-ZEMAIL,

ZFAX LIKE ZCUST_MASTER2-ZFAX,

ZSTAT LIKE ZCUST_MASTER2-ZSTAT,

end of itab1.

data : sr_dir TYPE dxfields-longpath VALUE 'E:\usr\sap\ECC\SYS\gen\dbg'.

data: FILE1 LIKE DXFIELDS-LONGPATH.

CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'

EXPORTING

I_LOCATION_FLAG = 'A'

I_SERVER = ''

I_PATH = sr_dir

FILEMASK = '.'

FILEOPERATION = 'R'

IMPORTING

  • O_LOCATION_FLAG =

  • O_SERVER =

O_PATH = FILE1

  • ABEND_FLAG =

  • EXCEPTIONS

  • RFC_ERROR = 1

  • ERROR_WITH_GUI = 2

  • OTHERS = 3

.

IF sy-subrc eq 0.

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

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

ENDIF.

OPEN DATASET FILE1 FOR INPUT IN TEXT MODE ENCODING DEFAULT.

do.

READ DATASET FILE1 INTO str.

if sy-subrc ne 0.

EXIT.

else.

split str at con_tab into itab1-zcustid

itab1-zcustname

itab1-zaddr

itab1-zcity

itab1-zstate

itab1-zcountry

itab1-zphone

itab1-zemail

itab1-zfax

itab1-zstat.

INSERT INTO zcust_master7 values itab1.

endif.

enddo.

CLOSE DATASET FILE1.

Reward Points, if useful.

Regards,

Manoj Kumar