cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any way to ignore first few fields from first row in .CSV file using FCC in Sender FTP??

Former Member
0 Kudos

E.G.

Partner Code,Partner Name,Partner Type,9/2/2013,,9/3/2013,,9/4/2013,,9/5/2013,,9/6/2013,,9/7/2013,,9/8/2013,

Here,i want to ignore first 3 fields since these are header and values for these fields come from next row.But i want to read dates.

How can i achieve?

Actually my aim is to read below file:

Partner Code,Partner Name,Partner Type,9/2/2013,,9/3/2013,,9/4/2013,,9/5/2013,,9/6/2013,,9/7/2013,,9/8/2013,

10,ABC,Full Time,7:00,15:00,7:00,15:00,10:00,18:00,10:00,18:00,10:00,18:00,10:00,18:00,,

,,,8.00,,8.00,,8.00,,8.00,,8.00,,8.00,,,

,56,SM,,,,,,,,,,,,,,

12,PQR ,Full Time,10:00,18:00,10:00,18:00,10:00,18:00,6:30,14:30,6:30,14:30,6:30,14:30,0:00,0:00

,,,8.00,,8.00,,8.00,,8.00,,8.00,,8.00,,0.00,

,56,ASM,,,,,,,,,,,,,,

27,XYZ ,Full Time,0:00,0:00,0:00,0:00,0:00,0:00,0:00,0:00,0:00,0:00,0:00,0:00,0:00,0:00

,,,0.00,,0.00,,0.00,,0.00,,0.00,,0.00,,0.00,

,56,BAR,ML,,ML,,ML,,ML,,ML,,ML,,ML,

It looks like attached file in Excel:

Thank you in advance!!

/Skrishnna S.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi All,

Have almost done...soon .will post the solution i followed ..

Former Member
0 Kudos

Hi All,

Need your quick help..

I am able to read the file with below FCC settings.

Here,i have used ABC as key since i don't have any key to use.

I could see success signal in sender adapter.But the payload doesn't contain any data.

Can you please tell me the reason for this?? This might be due to key which i have used.

/Skrishna S.

Former Member
0 Kudos

Hi

  You have a wrong understanding of the structure, from the information given in your posts above.

The Header comes only once, but you have given as Header,* - thats wrong, it should be 1 instead of *.

for each item you have defined a structure, which is not needed if they are same so it has to be item, * instead of item1,1, item2,1 etc...

Key value (if you want to use), has to be present in the data - which will actually separate the records..you have given as ABC, which is not in every record (except item1)..

so you need go through the tutorials thoroughly and redefine the structure and try it out..

Good luck

Regards

Vishnu

ambrish_mishra
Active Contributor
0 Kudos

Hi Skrishna,

My bad!

I missed noticing that your data does not have a key field. Without this you won't be able to segragate the header and item records like suggested earlier.

I can suggest an alternate solution. For that, I need some information.

Does the first line contains same number of fields(columns in excel) like other lines below ?

If yes, read the data through FCC (Line,*). Define the field names with delimiter as ,

Do 2 step mapping. In first mapping, map the first line/record to a intermediate structure having header and the rest of the lines as Item. Use collapse context to map the header and a UDF to ignore the first record and distribute the rest of the records as Item.

In the second mapping, map the intermediate structure to the IDoc structure.

Go step by step. Read the data as advised and then we can move ahead with the mapping.

Cheers,

Ambrish

Former Member
0 Kudos

Hi Vishnu,

Problem is, i have 3 rows in a single item.

How can i read these 3 rows using only item?

/Skrishna S.

anupam_ghosh2
Active Contributor
0 Kudos

Hi ,

                           Could you please explain your source XSD and the target XSD ? This will help the forum members to help you better , I guess. This problem cannot be resolved at FCC end, thus mapping needs to be addressed as well. To address mapping issues source and target XSD's are essential.

Regards

Anupam

Former Member
0 Kudos

Hi Anupam,

I am not sure whether i created correct source structure or not. PF below source xsd:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="https://ABC.com/weeklyattendence" targetNamespace="https://ABC.com/weeklyattendence">

   <xsd:complexType name="DT_TIMESHEET_SENDER">

      <xsd:sequence>

         <xsd:element name="Record" maxOccurs="unbounded">

            <xsd:complexType>

               <xsd:sequence>

                  <xsd:element name="Header" minOccurs="0">

                     <xsd:complexType>

                        <xsd:sequence>

                           <xsd:element name="Partner_Code" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Partner_Name" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Partner_Type" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Date1" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank1" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Date2" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank2" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Date3" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank3" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Date4" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank4" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Date5" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank5" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Date6" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank6" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Date7" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank25" type="xsd:string" minOccurs="0" />

                        </xsd:sequence>

                     </xsd:complexType>

                  </xsd:element>

                  <xsd:element name="Item1">

                     <xsd:complexType>

                        <xsd:sequence>

                           <xsd:element name="Code" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Name" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Type" type="xsd:string" minOccurs="0" />

                           <xsd:element name="To1" type="xsd:string" minOccurs="0" />

                           <xsd:element name="From1" type="xsd:string" minOccurs="0" />

                           <xsd:element name="To2" type="xsd:string" minOccurs="0" />

                           <xsd:element name="From2" type="xsd:string" minOccurs="0" />

                           <xsd:element name="To3" type="xsd:string" minOccurs="0" />

                           <xsd:element name="From3" type="xsd:string" minOccurs="0" />

                           <xsd:element name="To4" type="xsd:string" minOccurs="0" />

                           <xsd:element name="From4" type="xsd:string" minOccurs="0" />

                           <xsd:element name="To5" type="xsd:string" minOccurs="0" />

                           <xsd:element name="From5" type="xsd:string" minOccurs="0" />

                           <xsd:element name="To6" type="xsd:string" minOccurs="0" />

                           <xsd:element name="From6" type="xsd:string" minOccurs="0" />

                           <xsd:element name="To7" type="xsd:string" minOccurs="0" />

                           <xsd:element name="From7" type="xsd:string" minOccurs="0" />

                        </xsd:sequence>

                     </xsd:complexType>

                  </xsd:element>

                  <xsd:element name="Item2">

                     <xsd:complexType>

                        <xsd:sequence>

                           <xsd:element name="Blank7" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank8" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank9" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Hrs1" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank10" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Hrs2" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank11" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Hrs3" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank12" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Hrs4" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank13" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Hrs5" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank14" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Hrs6" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank15" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Hrs7" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank16" type="xsd:string" minOccurs="0" />

                        </xsd:sequence>

                     </xsd:complexType>

                  </xsd:element>

                  <xsd:element name="Item3">

                     <xsd:complexType>

                        <xsd:sequence>

                           <xsd:element name="Blank17" type="xsd:string" minOccurs="0" />

                           <xsd:element name="TotalHrs" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Mode" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Leave1" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank18" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Leave2" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank19" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Leave3" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank20" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Leave4" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank21" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Leave5" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank22" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Leave6" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank23" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Leave7" type="xsd:string" minOccurs="0" />

                           <xsd:element name="Blank24" type="xsd:string" minOccurs="0" />

                        </xsd:sequence>

                     </xsd:complexType>

                  </xsd:element>

               </xsd:sequence>

            </xsd:complexType>

         </xsd:element>

      </xsd:sequence>

   </xsd:complexType>

</xsd:schema>

I think you know source csv file. can u suggest some other structure for this.

Yet to get Target IDoc.First I am trying to convert it in XML at least.But payload doesn't contain any data after sender adapter process the file.

/Skrishna S.

ambrish_mishra
Active Contributor
0 Kudos

Hi Skrishna,

You can follow the approach suggested by me earlier. It will resolve your issue.

The records have same number of fields and FCC is possible.

Ambrish

Former Member
0 Kudos

Hi Ambrish,

Thanks a lot for your help!!

I am following your way and i have almost done this.

But i am facing 1 issue in this.Pls find below:

There are total 17 fields in each row.In some rows,last field is coming as blank.therefore,the last field in a row is not getting created.and this is resulting in a mapping failure issue like below:

Error is due to missing last blank field:

Can you tell me how to create last blank field.

Thanks again for your help!!

/Skrishna S.

gagandeep_batra
Active Contributor
0 Kudos

Hi Shri,

You can handle this in mapping by mapwithdefault function

Regards

gAgan

Former Member
0 Kudos

Hi,

Problem is, i have 3 rows in a single item.

How can i read these 3 rows using only item?

  Not sure how far you have gone with mapping & logic..the item is something that you define in the FCC, you can define, each row as an item (probably thats what is intended in the CSV). so for your CSV file. there will be One header & 3 items, as explained above in couple of my posts (the expected pseudo structure and the pseudo FCC definitions). This may enable you to directly map your converted XML to target Idoc, with easier loopings/ data retrievals as expected in Idoc structure...

Regards

Vishnu

ambrish_mishra
Active Contributor
0 Kudos

Glad to know that you are almost there.

Use lastFieldsOptional or similar parameter in the FCC to avoid this error.

Cheers!

ambrish_mishra
Active Contributor
0 Kudos

Hi, please check the link below

http://help.sap.com/saphelp_nw04/helpdata/en/2c/181077dd7d6b4ea6a8029b20bf7e55/content.htm

You can try NameA.missingLastfields

Cheers

baskar_gopalakrishnan2
Active Contributor
0 Kudos

If you want to remove first line you can use documentoffset = 1.  If possible, move the required fields in the next following line and ignore the first line. If that is not possible and business requirement does not support then ignore unwanted fields in mapping....  Don't map it to target side. This is easiest solution.

ambrish_mishra
Active Contributor
0 Kudos

I am with Anupam. This is not possible.

However, I have a suggestion. Read the first line as Header and second line onwards as Line items. This way you can utilize the data values and the queues for line items will remain undisturbed.

Cheers

Ambrish

Former Member
0 Kudos

Hi Ambrish,

I can't read first row as header since all fields in first row are not constant (like date)..

So,Is there any other way??

Waiting for your response..

/Skrishna S.

Former Member
0 Kudos

Hi,

So,Is there any other way??

  Depending on your "expected" converted XML (CSV to XML) and "expected" mapping output (XML to target XML), you can derive the data that you needed. you have only discussed about the first part of your scenario.

So it is does not matter whether you take these fields in header or body, depending on what data you need and at which stage you need.

If you definitely dont want to even "read" the values of the first 3 fields, then there is one suggestion that you can try, define the entire set of fields (Partner Code,Partner Name,Partner Type,) as a "Key". you can try to see, if it works. "Key" is a field that will not come in actual data structure. But as mentioned earlier, a lot of things depends on the way how you need your converted structure (before mapping, if any) to look like and also how the idea of using "Key" works in FCC in this case (am curious).

you can follow these for reference

http://saptechnical.com/Tutorials/XI/Contentconversion/page1.htm

http://saptechnical.com/Tutorials/XI/Contentconversion/page2.htm

http://www.riyaz.net/sap/xipi-file-content-conversion-for-simple-structure/75/

http://www.riyaz.net/sap/xipi-file-content-conversion-for-complex-structures/79/

good luck

Regards

Vishnu

Former Member
0 Kudos

Hi,

I would do almost similarly like Ambrish suggested.

Since you did not mentioned how many dates etc in header field can contain, I assume file can contain varied amount of dates. For that reason my solution is to read lines without header using structure like Recordset, Line (contain whole line).

Then you can build XSLT mapping for this where you loop lines so that in code you will check the "header-line" (for example first field contain value"Partner Code" separated by comma) and like this get the dates into variables or just loop this header-line based on fields (comma separated) and add item-lines under each header-line date. Also with XSLT you can get rid-off unwanted fields easily. Then you can map this structure into required output structure. This is not probably best solution but should work even though might generate quite big loops depending on amount of lines in file.

I assume you have no need to do some custom module coding mentioned in link:

http://scn.sap.com/people/community.user/blog/2005/07/04/read-excel-instead-of-xml-through-fileadapt...

Cheers, Mika

Former Member
0 Kudos

Hi Vishnu,

Thanks for the reply!!

Target structure is IDoc.

So,somehow i need to read this file and get it converted in XML so that i can map the input fields to IDoc fields easily.

Coming file is weekly timesheet of the employees.

It looks like below in Excel:

So Request you all to provide some solution on this.

Thanks in advance!!

/Skrishna S.

Former Member
0 Kudos

Hi

As you will be having a mapping step, you can ignore the fields at that stage, rather than complicating at FCC. so I dont see a reason why you need to ignore these fields during FCC. as explained in one of the tutorials, you need to define a structure (CSV to XML) which will be more or less same as CSV (but XMLised). for ex (you can have any name for the field/ tag names, below is for ref).

After FCC

<Root>

     <Header>

          <Field1>Partner Code</Field1>

           ......

          <FieldN>date value or empty</FieldN>

     </Header>

     <Partner_record> <Pcode>10</Pcode>..........<lastfield></lastfield></Partner_record>

       ........

      <Partner_record> <Pcode>27</Pcode>..........<lastfield></lastfield></Partner_record>

</Root>

Now you can map this XML structure to Idoc, where you can ignore, loop, repeat the fieldvalues as you needed.

Best of luck

Regards

Vishnu

ambrish_mishra
Active Contributor
0 Kudos

Hi Skrishna,

>>>>>>I can't read first row as header since all fields in first row are not constant (like date)..

this is simply a workaround. Read all the value as header fields (I assume the number of fields is constant). Use the values which you want and ignore the rest.

Ambrish

anupam_ghosh2
Active Contributor
0 Kudos

Hi Shrikrishna,

                          I don't think this is possible at FCC level.

However you can ignore the fields at mapping level.

Please wait for expert's to respond on the same.

Regards

Anupam