Writing to flat file

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.

Any help/quidence greatly appreciated

Regards

Tony Mundy

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!

Hi VR,

Thanks for the prompt reply.

How would you write the data out to the file?

Ta

Tony

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!

Specifically, take a look at the examples in Igor’s Toolbox package in the File Share area. Here’s a link: [url=“wmusers.com”]wmusers.com

Mark

Once again, thanks for the quick response.

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)

Thanks again

Tony

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!

Jamie Stanton
Innotrac

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.

Thanks again for any help

Regards

Tony Mundy

Tony,

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:

  1. You are mapping your flat file record structure to the
    Values input.
  2. You are mapping your flat file template to the
    EDITemplate input.
  3. 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.

FlatFileRecList ------------- mapped to -------------
Values
–FlatFileRec
-----Field1
-----…
-----…
-----FieldN

boundnode
—FlatFileTemplate --------------- mapped to -----------
EDITemplate

Mapping the FlatFileRec level to Values or mapping the
boundnode level to EDITemplate could result in the null
error.

HTH

Hi Chris, thanks for the reply.

convertToString is getting input, very simply I have
specified a document with two fields and hard coded the
values.

EDITemplate is not used in convertToString in version 6. I
have stepped through and data is definatly getting into
convertToString.

Tony,

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

Hello Tony and Patrick,
Try running the ConverttoString separately, by passing the values of the Record and the EDI Template through the input screen.

If this is working fine, then I guess, there is some problem with your mapping of the input variables to the ConverttoString service.

Good Luck

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

PB,

Please make sure the result 846 document structure that mapping to ffValues is exactly confirms with EDIFFSchema.

Are you seeing any error in logs?

HTH,
RMG

Hi

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

And this worked for me.

PB

If you set either ffschema or nsrecord convertToString work as expected.But always using schema it is good.

HTH,
RMG

Hi professionals,

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.

Thanks in advance

Regards
R

Raghu,

In Recordlength column (specify each record length would be)say if the records end at 30 then enter this number.

HTH,
RMG

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.

Thanks & Regards
R