Priyatham saab,
Here are the few answers regarding,see if it can helps
1Ans)Once you load and extract the flatfile data based on the Schema/documenttype,you will see the Header and Lineitems (16 record).So use the WmPublic service (pub.list:sizeOfList)to get the count of lineitems or else using loop step ($iteration) param you can get the count (1,2,3,4…)
2Ans)Using JDBCAdapter CustomSQL or DynamicSQL or Storedprocedure you can call that package/function.
3Ans)The error indicates that you are trying to map a string field which is already mapped.you can do this if the variable is a list.
By the way are you mapping the B12 flatfile to some canonical document that will be used to insert into DB tables?
HTH,