Branch + Schema giving strange output

I’m a real novice, but here it goes :

I have a branch defined in my mapping that checks if an input record contains a certain variable that isnt null. If this field is found, it maps across from the input a single item (the one checked for) and 2 other elements. If it is null, nothing done.

My output flatfile schema has a 22 character line defined for the 3 elements.

Now the mapping loops through the input, checking each record for the value, writing it to the output if exists.

When I check the output file, the first, and only instance of the element being checked for is there, correctly filling the 22 characters. Yet as i check further down the output I notice that where ever the line should have been, but wasnt due to it not existing in the input, there is now a 22 character blank field. Is there any way to supress this line being printed if the value is null?


Before you check the field, trim it to null - it may be coming through as spaces which is why you’re getting values.


How is your loop defined? If you declare an output array in your loop, an entry will be created for every loop iteration regardless of branching/mapping. If you need to have a list with entries that are conditional, remove the output array setting from your loop and use appendToDocumentList (if you are accumulating only a few hundred elements or less–if more, you’ll want to use a different technique because appendToDocumentList is very inefficient when lists grow beyond a few hundred).

Its 10 records atm, less then 100 later on.

I think its more to do with the schema, I read through the pipeline at every loop and found that there were no values being created if what I was looking for wasnt there.

In the schema I have 2 lines defined :

recordWithNoID - not Mandatory
IDSEGMENT(0-7) -‘PRD001’
TYPE(7-10) -‘HN’
NOHEAT(10-22) -‘xxxxxxxx’

recordWithNoID - Mandatory
IDSEGMENT(0-7) -‘PRD001’
TYPE(7-10) -‘SN’
IDSTK(10-22) -‘xxxxxxxx’
FILLER(22-206) - spaces

The NOHEAT value is the one I check the input for in the branch.

Now, after converting to string and checking my output I find :

On the first time, where I know there is a NOHEAT value in the input :

PRD001HN 7852649
PRD001SN G24144P1

This is correct, now, on all the times after that I get :

PRD001 SN G28879P1R

it seems that it prints IDSEGMENT, then all of the NOHEAT line as blanks, then TYPE, IDSTK, FILLER.

is there a problem with having a non mandatory line starting with IDSEGMENT then the mandatory line after it with IDSEGMENT aswell?