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

concatenatio again

Former Member
0 Likes
723

sorry friend ur replies in earlier query ll not solve my problem...

now i m elaborating my problem ..

i have to upload data from flat file..

then i want to concatenate all fileds into a string , row by row...and compare this string with that of string fetched from database record..

many fields may contains blanks so these blanks should not be supressed..

i think i defined my problem properly...

please help..

Message was edited by: Madan Gopal Sharma

sorry friend ur replies in earlier query ll not solve my problem...

now i m elaborating my problem ..

i have to upload data from flat file..

then i want to concatenate all fileds into a string , row by row...and compare this string with that of string fetched from database record..

many fields may contains blanks so these blanks should not be supressed..

i think i defined my problem properly...

please help..

Message was edited by: Madan Gopal Sharma

5 REPLIES 5
Read only

Former Member
0 Likes
700

hi,

When you are getting from file, you will be knowing the length of fields in the file. You can use offset for solving ur problem.

try like this.

START-OF-SELECTION.

DATA: T1 TYPE C VALUE '1',

T2 TYPE C VALUE space,

T3 TYPE C VALUE '2',

T4(4) TYPE C.

t4+0(1) = t1.

t4+1(1) = t2.

t4+2(1) = t3.

write 😕 t4.

Output will be 1 2.

Regards,

Sailaja.

Read only

Former Member
0 Likes
700

Hi Madan,

Before concatenating the fields, check whether it is initial.

If so do the following

LV_FIELD = <ASSIGN A SPECIAL CHARACTER>.

When all the fields are checked you can concatenate them into LV_STRING.

After that do the following

REPLACE <ASSIGN A SPECIAL CHARACTER> WITH space INTO LV_STRING.

Now you can compare with the string from the table.

Regards,

Sameena

Message was edited by: sameena attarwala

Read only

Former Member
0 Likes
700

Hi,

Use offset for this problem..

t1 = 'abc'.

t2 = ' '.

t3 = 'cde'.

t4 = t1.

t4+3(3) = t2.

t4+6(3) = t3.

t4 has the value.

i have assumed the lenght to be 3.

U need to know the length or else calculate it using strlen n use it as t4 = t4+strlen_t1(strlen_t2)

Regards,

Tanveer.

Mark helpful answers

Read only

Former Member
0 Likes
700

Madan,

A Quick thought

CONDENSE the records from the file as well as the Database record, then it will have one blank space between each of the strings. Now, you can compare the records.

If you have to consider BLANKS also, then this logic will NOT work.

Regards,

Ravi

Note : Please mark the helpful answers

Read only

Former Member
0 Likes
700

Hi Madan,

1. To upload data from flat file and then concatenate the data row by row into a string , you can use the following code.

REPORT ZKUN_FILE8 .

tables : zkunal1.

data : begin of itab1 occurs 0.

include structure zkunal1.

data: end of itab1.

data : begin of gv_itab occurs 0.

include structure zkunal1.

data: end of gv_itab.

data : gv_file type string,

str1 type string.

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

*SELECTION SCREEN *

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

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS: p_file LIKE ibipparms-path obligatory. " For file selection

SELECTION-SCREEN END OF BLOCK b1.

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

*AT SELECTION SCREEN *

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

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

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

START-OF-SELECTION.

  • P_FILE is not compatible with the FM GUI_UPLOAD, so pass it to

  • GV_FILE.

gv_file = p_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = gv_file

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = '#'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = gv_itab

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

IF sy-subrc <> 0.

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

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

ENDIF.

loop at gv_itab.

write : / gv_itab-mandt, gv_itab-fname, gv_itab-lname, gv_itab-place.

concatenate gv_itab-mandt gv_itab-fname gv_itab-lname gv_itab-place into

str1

.

write / str1.

endloop.

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

Now you can see the str1 has the data from the flat file .

If you tell me how you are fetching the data from your database, i can tell you how to do the comparison also.

Thanks and Regards,

Kunal.

Note :

1. The table Zkunal1 is a transparent table with fields as MANDT FNAME LNAME PLACE.

2. The file you want to upload should be the having the data in the same sequence .

for example , the file can have data as :

100 Madan Sharma India.

( the data should be tab separated ).