Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Dynamically fetching first column in internal table based on flat file

Former Member
0 Likes
1,367

Hi All,

Let me explain this scenario.

I have a flat file which will be uploaded for a BDC. Based on which type pf business is operating we have two types of flat file template ->

Business 1 : Template

Land1

LIFNR

Bank details

Business 2 Template

LIFNR

BANK DETAILS.

In any case for further processing , I need the first column to be there which is LAND1. How do in create column 1 to my internal table at runtime and proceed.Also the other columns are fixed and will not change.

Please help.

Thanks

AS

Hi All,

Let me explain this scenario.

I have a flat file which will be uploaded for a BDC. Based on which type pf business is operating we have two types of flat file template ->

Business 1 : Template

Land1

LIFNR

Bank details

Business 2 Template

LIFNR

BANK DETAILS.

In any case for further processing , I need the first column to be there which is LAND1. How do in create column 1 to my internal table at runtime and proceed.Also the other columns are fixed and will not change.

Please help.

Thanks

AS

9 REPLIES 9
Read only

archanapawar
Contributor
0 Likes
1,343

Hi Swarna,

I think it is difficult to generate LAND1 column at runtime while reading dataset into internal table.

Did you try offset method to determin whether your first column is LAND1 or LIFNR?

May be based on that you can pass you record into respective internal table.

Read only

former_member182888
Participant
0 Likes
1,343

Please clarify and give example to your Flat file records

Read only

0 Likes
1,343

Hi ,

In case of Business 1

LAND1 LIFNR TAXID NAME1 SORT1 etc

In case of Business 2

LIFNR TAXID NAME1 SORT1.

Here in case of business 2 i need to add a column LAND1 at run time after uploading the flat file and set it to a specific country value.

Could you please help,

Thanks

AS

Read only

0 Likes
1,343

Hi swarna,

Did you try offset method? You can get the content of read dataset into a string type first and check the first field whether it is LAND1 or LIFNR. Further you can divide it as per your requirement.

Read only

0 Likes
1,343

thank you

ok,

you will concatenate the desired value to the beginning of the record

Read only

0 Likes
1,343

Hi Archana,

Could you please explain as im a bit confused here.

Thanks

AS

Read only

0 Likes
1,343

Hi Swarna,

Data element LIFNR is char10 and LAND1 is char3. So, define a work area type string.

Then read dataset into work area.

After reading into work area, split your work area at your file separator e.g. ' '(space) into 2 variables.

Read the length of first variable, if its 3, then it is LAND1 field and if it is more than 3 that means field is LIFNR.

Below is sample code.


DATA: wa_text TYPE string,

       lv_text1 TYPE char10,

       lv_text2 TYPE char10,

       lv_count TYPE i.


READ DATASET lv_path INTO wa_text.

split wa_text at ' ' into lv_text1 lv_text2.

lv_count = strlen( lv_text1 ).


if lv_count eq 3.

*- read dataset again to internal table with LAND1 and remaining columns.

else.

*- read dataset again to internal table for LIFNR.

ENDIF.

Hope it helps. It should work.

Read only

0 Likes
1,343

Hi Swarna,

Did you try this solution?

Read only

VenkatRamesh_V
Active Contributor
0 Likes
1,343

Hi,

Try with the  Excel format  using  FM ALSM_EXCEL_TO_INTERNAL_TABLE .

Hope it helpful.

Regards,

Venkat.