This website is not affiliated with, sponsored by, or approved by SAP AG.

ABAP Code for Multiple Fields to Single InfoObject

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

ABAP Code for Multiple Fields to Single InfoObject

Postby iskhan » Mon Oct 13, 2014 1:06 am

Hi

In CSV file there are Spare Part Name and its Unit Cost repeat 10 times i.e. 20fields like Part1&Cost1,Part2&Cost2................... Part10&Cost10
90% Part1&Cost1 to Part5&UCost5 fields are filled it means Part6&Cost6 to Part10&Cost10 are empty.
in other words
10% Part1&Cost1 to Part10&Cost10 fields are filled.
And ZSPR_PART and ZUNIT_CST are the single info objects for Part1 -10 and Cost1 -10

So I map the Part1 to ZSPR_PART and Cost1 to ZUNIT_CST in transformation only.
And Write Start Routine as:

Code: Select all
LOOP AT SOURCE_PACKAGE ASSIGNING <source_fields>.
IF <source_fields>-PART1 is NOT INITIAL AND <source_fields>-Cost1 IS NOT INITIAL .
*Nothing to do
ELSEIF <source_fields>-PART2 is NOT INITIAL AND <source_fields>-Cost2 IS NOT INITIAL .
<source_fields>-PART1 = <source_fields>-PART2.
<source_fields>-Cost1 = <source_fields>-Cost2.
ELSEIF <source_fields>-PART3 is NOT INITIAL AND <source_fields>-Cost3 IS NOT INITIAL .
<source_fields>-PART1 = <source_fields>-PART3.
<source_fields>-Cost1 = <source_fields>-Cost3.
...................................................

...................................................
ELSEIF <source_fields>-PART10 is NOT INITIAL AND <source_fields>-Cost10 IS NOT INITIAL .
<source_fields>-PART1 = <source_fields>-PART10.
<source_fields>-Cost1 = <source_fields>-Cost10.
ENDIF.
ENDLOOP.

But it shows the following error:
The data object "<SOURCE_FIELDS>" has no component called "PART2", but there is a component called "PART1".

How to resolve this issue?
iskhan
 
Posts: 22
Joined: Mon Nov 02, 2009 11:55 pm

Re: ABAP Code for Multiple Fields to Single InfoObject

Postby Grogan » Mon Oct 13, 2014 3:10 pm

Perhaps it would help if you included the type declaration for <SOURCE_FIELDS>.
Grogan

Award cash if useful.
Grogan
 
Posts: 365
Joined: Thu Aug 04, 2005 7:16 pm
Location: Australia

Re: ABAP Code for Multiple Fields to Single InfoObject

Postby iskhan » Mon Oct 13, 2014 10:12 pm

You mean some thing like this:
SOURCE_FIELDS-PART2 TYPE C LENGTH 20.
SOURCE_FIELDS-PART3 TYPE C LENGTH 20.
:::::::::::::::::::::::::::::::::
SOURCE_FIELDS-PART10 TYPE C LENGTH 20.
iskhan
 
Posts: 22
Joined: Mon Nov 02, 2009 11:55 pm


Return to ABAP

Who is online

Users browsing this forum: No registered users and 7 guests



cron


loading...


This website is not affiliated with, sponsored by, or approved by SAP AG.