on 02-24-2015 2:22 PM
Hi,
I have a flat file datasource which I need to add an additional column to as it doesnt contain certain data. This will be based on the file name. for example, if the file name contains USA and then column should contain USA.
The options I have is to
1. Amend the file in the process chain via ABAP to add the column
2. add a start routine to the transformation - i dont think this is an option as the column does not exist in source so cant do a start routine.
3. add a end routine to the transformation to update the value OR use a routine on the actual mapping in the transformation (if no source mapping included it still lets me add a routine. Which option would be best - would the end routine only be called once? if I did the routine in the actual transformation would it go an check the file name for each record which would be an unnecessary overhead?
Views?
Cheers,
Hi Leo,
My recommendation:
1) Using tables RSREQDONE & RSFILENAMEDONE you can derive file name in a variable in start routine.
OR
You may replicate the logic used in infopackage to derive file name in start routine (Check all scenarios here).
2) In Transformation Routine (Mapping), read the variable derived in start routine & based on IF_ELSE assign country name to target field.
You don't need to have a source field to write a routine for target field.
Regards,
Arun Purohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You mentioned
You don't need to have a source field to write a routine for target field.
Are you saying it should be possible to do a start routine for a target field? My understanding was that the start routine amends the data as it comes in. If it does then I need to map that field i have amended to target.
However, I was now thinking maybe i could put a dummy source field in the datasource which is not populated by the flat say called country - then this could be amended by the start routine. I could map this field to target?
I am assuming in this scenario the start routine would only be called for each package?
Cheers,
If you have piece of ABAP that tells you the file name, then you'll need either a combination of Start+Field Routine, or write all the code in the End Routine.
Start+Field Routine approach:
End Routine approach:
Hi,
From a performance perspective which is the most appropriate method?
Start+Field Routine approach or End Routine approach?
Start+Field Routine approach: In this way is the file name code run each package and then written for each row in the field routine?
End Routine approach: In this method is the file name code run each package and then at the end of package the file name written to each row?
If my assumptions are correct the "End routine approach" sounds like slightly a better approach and also the code is all in one place?
Views
Hi Leo,
I don't think that there would be any significant difference in performance between these two approaches.
But yes technical difference is there:
1) End Routine: all code is there at one place, but you will need to write few more lines of code as compared to other approach as you need to do additional looping in code in result package.
2) Start routine + Field Routine: Though code is at different places, fewer lines of code is required. You need not do additional looping manually, as Field routine executes record by record (which is loop only).
I would recommend Start-Routine + Field Routine due to one less Loop.
Thanks
Hi Leo,
As I understand here, you need to write a routine for loading flat file to PSA.
Here how come start routine, end routine or expert routine comes into picture?
Only routine that can be written at this stage is in the infopackage level for selecting files with dynamic names.
or you can write a separate ABAP program and include it in your process chain which will check the file as soon as it comes in application server and loads it to your datasource.
Here you can create multiple datasources (if there are few values for country) and code it in your program which PSA to load depending on your file name.
Thanks,
Akanksha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Regardless of start/end/expert routine, how exactly would you get the name of the flat file in your transformation? Are you using a different datasource for each file?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
If the plan is just to add the column it to the DSO, I would suggest the ff:
1. on start routine, get the file name and assign in to the global variable.
2. on transformation, create a routine of the infoobject and assign the global variable.
if the plan is just to add a column inside flat file, ABAP would be the best.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Leo,
1. Amend the file in the process chain via ABAP to add the column
This option will be most suitable option.
3. add a end routine to the transformation to update the value OR use a routine on the actual mapping in the transformation (if no source mapping included it still lets me add a routine. Which option would be best - would the end routine only be called once? if I did the routine in the actual transformation would it go an check the file name for each record which would be an unnecessary overhead?
If you are doing it in end routine then the file name will be called only once for each package but need to update all records using loop statement. Better option will be doing it in file.
Thanks,
Shakthi Raj Natarajan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I could be wrong but don't you have to loop over the whole file in option 1 anyway to populate the field? Plus you then have the added overhead of opening the file and writing to it to then have to reopen it for reading to the PSA?
Personally I'd go for option 3 and use an end routine as you would only need to read the file once, only need to set the value for the new field once (in the end routine) and then do a loop over the result package to assign the value to the field.
Regards,
Gareth
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.