Using STM_File_Read / Transform_File to process Text file

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
eddie9394
Posts: 23
Joined: Tue Aug 14, 2018 11:03 pm

Using STM_File_Read / Transform_File to process Text file

Post by eddie9394 »

I am using the STM_FILE_Read / Transform_file to read the CSV file and create worklist. I had about 700+ records in the file and it stop at some record with bad data Cafe with the funny E. Any one know how to deal with funny character and force it to continue to read until the true EOF is reach? THANK!

I tried both:
use builtin(TRANSFORM_FILE) with_args(#WRKLIST #WK_String1 "O" "B") to_get(#RETNCODE)
this will stop at record 50, the Cafe is at record 68

use builtin(STM_FILE_READ) with_args(#FILENO) to_get(#wk_string1 #RETNCODE)
this stop right at 68 and jump out the DoUntil RetnCode=EF loop
MarkDale
Posts: 116
Joined: Wed Dec 02, 2015 10:06 am

Re: Using STM_File_Read / Transform_File to process Text file

Post by MarkDale »

One thing you could try is saving and restoring the CSV file using the UTF-8 option.

To do that you use TRANSFORM_FILE and TRANSFORM_LIST, but you add a U to the format - e.g. in your case the format would be OU.

That might avoid the funny character problem.
eddie9394
Posts: 23
Joined: Tue Aug 14, 2018 11:03 pm

Re: Using STM_File_Read / Transform_File to process Text file

Post by eddie9394 »

Mark, Thanks for the Reply! I try removing all the funny characters in the CSV file the STM_File_Read read all the records, but transform_file only read the first 50 records

Code: Select all

* Transform File
use builtin(TRANSFORM_FILE) with_args(#WRKLIST #WK_String1 "OU") to_get(#RETNCODE)
#wk_int6 := 0
selectlist named(#WRKLIST)
#wk_int6 += 1
#SYS_APPLN.TraceMessageText( ("Tranformed:[&1]->[&2][&3][&4][&5]").Substitute( #wk_Int6.AsString #ULOFID #ULTRAN #ULAMT.AsString #ULDESC ) )
endselect

* STM_File_Read 
dountil cond('#retncode = EF')
use builtin(STM_FILE_READ) with_args(#FILENO) to_get(#wk_string2 #RETNCODE)
if cond('#retncode *EQ ER')
#SYS_APPLN.TraceMessageText( ("Read Error =[&1]").Substitute( #RETNCODE ) )
endif
if cond('#retncode *EQ OK')
#wk_Int6 += 1
#SYS_APPLN.TraceMessageText( ("Data Content=[&1:&2]").Substitute( #wk_int6.AsString #wk_String2 ) )
endif

enduntil
In the case that I have funny character in row 15, both operations will stop at 15
when i put the funny character in row 65, Transform_File still stop at 50, STM_File_Read stop at 65
eddie9394
Posts: 23
Joined: Tue Aug 14, 2018 11:03 pm

Re: Using STM_File_Read / Transform_File to process Text file

Post by eddie9394 »

Change the #WRKLIST entrys to *max, now the Transform_File works. Bad character issue remain unsolved!
Post Reply