I am having difficulty writing to a fixed length flat file.
I need to read records from an AS400 physical file then write them to a flat file on a 2000 server. I can read the file from the AS400 using execsql but am not sure how to write the records to the fixed length flat file, I have created a flat file schema to be used in the flow. I have tried using convertToString service but am getting no data in the string output of this service even though data is going in to the service.
How many records do you fetch in one operation?
If your results from execSQL has only a list of strings inside then it is easy.
You can loop over the results structure and then do a simple map from each item to a string.
Hope this works.
Good luck!
You can write the data to a file using the utilities which are uploaded here in wmusers.
You can download that here.
Hopefully you are able to get the data from the database query now.
Thanks and Good Luck!
I can get the data from the AS400 without problem and populate a document list. I then need to convert this in to the flat file layout for which I have created a flatfile schema. My problem still lies in writing the records/fields that are in the flat file schema to the acctual flat file on the server. I have downloaded the zip file you mentioned Mark, problem is I think this has been written specifically for 4.6 rather than version 6 which we are on. One thing to note I have limited knowledge of Java.
The flow I have created goes something like this
connect (connect to As400)
execSQL (get the data from the as400)
LOOP (over all records in file retrieved)
MAP (from document list to flat file schema)
I got something similar to work, here was what I did. First I leveraged the WmSamples.samples:IO example. It gives you a basic java filewriter level of IO. So, adding to your example I’d do the following:
connect
execSQL
openFilewriter (specifying filename)
LOOP
MAP (using convertToString from the flatFileIO to convert the document to a string – STILL IN LOOP)
writeFileWriter (passing the string just created – STILL IN LOOP)
ENDLOOP
flushFileWriter (you might need this inside the loop for large data)
closeFileWriter
That’s basically what I did and it worked. I hope this helps!
Another way is to use your execsql and add the following:
stringtodocument service appling your flatfile template as input
output of stringtodocument service to be input to documenttorecord service
converttostring service using output of documenttorecord service as input for template and using your list string as data values input.
that’s it and it will produce a flat file format of string data for you to use on Sql Server. Keep in mind that the high-level structure names of both converttostring inputs must match and your xml flatfile template must conform to webMethods rules. These 2 pieces are critical!
I am still no farther forward ( i’m beginning to think i’m
thick). What I am trying to do sounds so simple and yet is
proving quite the opposite. All I want to do is take an
AS400 Physical File (any number of records and 36 fields in
each) and from that create a flat file. My main problem is
getting results fro m convertToString (I don’t get any).
I am noe trying something simple, one map service and
convertToString, I am mapping two fields in a document into
convertToString. I am supplying a Flat File schema in
convertToString which is very basic two fields. When I run
the service the output from convertToString in blank and the
error field is null.
I’m moving to 6.0 this week but here’s my 2 cents.
Your problem seems to be convertToString not getting any
output. Check the following:
You are mapping your flat file record structure to the
Values input.
You are mapping your flat file template to the
EDITemplate input.
Step thru your flow and stop at convertToString. Then
view your Results tab. Double chech that the structure of
your template is the same as your flat file structure. The
problem you’re describing I have seen before. If my memory
is correct it had to do with different structures between
the flat file template and the flat file record structure.
Have you gotten anywhere with this ? I am having the same issue. I am now trying to duplicate the example from edi reference appendix A for FLR output. My result is a null error and an empty string. If you have had any success I would be interested to here what you did.
Pat Sclafani
Hi,
I’m facing a similar problem wherein I have a document type based on a 4010.X12.846. I’m reading values from a database and populating this document (it works till here), and then calling the wm.b2b.edi:convertToString service by mapping this document type ref to the Values input in convertToString. The resultant string I get is empty. Can someone tell me what I missed?
Thanks
Found the solution. Apparently the BIS guide is incorrect in this case - or at least inconsistent with the WmEDISamples service and also with what really worked for me.
Although the document says that the value of input variable “ffschema” needs to be set the the EDI 846 schema, I had to blank out the value for the ffschema, and set the value of the document type (EDIFFSchema.X12.V4010:T846) to the input variable “nsrecord”. (I followed the WmEDI samples here.)
I am trying to use flat file schema for converting XML data to positional EDI file . While creating flat file schema for fixed length what do I need to give in the Record length column in( Flat File structure). I am not getting a correct output when I use convert to string service . I feel my flat file schema creating is wrong .Anybody please help.
Hi,
Thanks RMG. My question is I am trying to define a record count for EDI (back end format) file . Each record if of different length. Then how do I give the lenght for the same.