on 03-09-2007 12:12 PM
Hi,
Could you please help me to write a start routine to bring data from a flat file with a file name week45_c1_pri_2006, where the wekk name week-- changes per week. how to track the filename in the routine and how in data transfer process knows to load data from each flat file.
Message was edited by:
Anima M
PROGRAM trans_routine.
----
CLASS routine DEFINITION
----
*
----
CLASS lcl_transform DEFINITION.
PUBLIC SECTION.
Attributs
DATA:
p_check_master_data_exist
TYPE RSODSOCHECKONLY READ-ONLY,
*- Instance for getting request runtime attributs;
Available information: Refer to methods of
interface 'if_rsbk_request_admintab_view'
<b>p_r_request
TYPE REF TO if_rsbk_request_admintab_view READ-ONLY.</b>
<i>The bold area above where you get the requestid, here I am stuck.
The below code does not bring the correct requestid of PSA</i>
CALL METHOD P_R_REQUEST->GET_REQUID30
RECEIVING
R_REQUID30 = IREQUID.
CALL METHOD P_R_REQUEST->GET_REQUID
RECEIVING
R_REQUID = IREQUID.
SELECT FILENAME INTO IFILENAME FROM rsseldone WHERE rnr = IREQUID AND lnr = ' 1'.
Hope this can give a better picture where I am currently stuck not able to get the PSA request id in the <b>start routine of transformation</b> to read the data and filename from there.
Thanks alot
Anima
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I never do that.....but i made some programs in ABAP that load a flat file in background....i assume that i works like that.....use the OPEN DATASET statement .....you need to put your flat file in the BW server....the statement needs the file name and directory and load the data into an internal table.....
Put this statement into your extractor FM and include the data in the E_T_DATA internal table
The Filename is given as a string to the statement and you could some logic to change the filename by week....
Regards
Message was edited by:
Oscar Díaz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you please ellaborate on your approach more detailed(step by step)
what transaction or routine to use to do ..<b>"OPEN DATASET statement .....you need to put your flat file in the BW server....the statement needs the file name and directory and load the data into an internal table......."</b>
I do not know where to go and do the above steps.
Thanks alot
Hi Anima,
Start Routines atre not the right place to determine filenames dynamically.
In info package tab ''External Data' button 'Create routine you can do it.
Sample code:
DATA: Z_WEEK TYPE KWEEK,
Z_YYYY(4),
ZZ_WW(2).
*Derive week form sy-datum
Break-point.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
DATE = 'SY-DATUM
SY-DATUM
IMPORTING
WEEK = Z_WEEK.
EXCEPTIONS
DATE_INVALID = 1
OTHERS = 2
Z_YYYY = Z_WEEK(4).
ZZ_WW = Z_WEEK+4(2).
*DIRECTORY represnts path where file is stored .
CONCATENATE 'DIRECTORY' 'WEEK' ZZ_WW '_c1_pri_' Z_YYYY into p_filename.
*....
p_subrc = 0.
According to your requirement week and year will be replaced based on sy-datum.
If you want to schedule info package in a process chain you have to store file
on application server and to check corresponding radio button.
'Directory' then shuld represent logical path name of your OS (AL11),
Hope this helps
Joe
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the code.
In my scenario, based on the filename, I need to decide on the week and the year not on the system date, for the chances are the files would not be available for load on weekly basis.
From the filename(ZZZC145.csv) I need to get the week, c1 stands for channel 1, zzz stands for performance period which is required in the report as fields.
Hope you can help me in this.
Thanks alot
Hi Anima,
Sorry, I completely misunderstood your requirement. I assumed, that you want to create a file name for upload dymamically. Your issue can be solved ,as you mentioned, at start routine of transfer rules.
Structure G_S_MINFO provides Request-ID which is stored in table RSSELDONE in combination with a filename.When filename is determined, you only need an offset and you can derive character strings as desired
Here is a sample code. Please customize it according to your scenario.
Start routine of transfer rules:
DATA : Z_FILE(128) TYPE C.
DATA : Z_LEN(3) TYPE N.
DATA : Z_WW(2) TYPE N.
SELECT single FILENAME FROM RSSELDONE INTO Z_FILE
WHERE RNR = G_S_MINFO-REQUNR and LNR = 1.
condense Z_FILE no-gaps. .
Z_LEN = strlen( Z_FILE ). "legnth of string
Z_LEN = Z_LEN - 6. "subtract length of 45.csv for offset
Z_WW = Z_FILE+Z_LEN(2).
LOOP AT DATAPAK.
DATAPAK-WW = Z_WW.
Modify DATAPAK.
ENDLOOP.
Regards
Joe
Hi Joe,
Thanks a lot for your input.
The BW version is 7. Here I need to write the code in Start Routine for the transformation. In the Start Routine I coud not find the Structure G_S_MINFO.
This rnr = <b>"G_S_MINFO-REQUNR"</b> is giving an error as below
E:Field "G_S_MINFO-REQUNR" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement. "DATA" statement. "DATA" statement
Thanks
Anima
Hi Anima,
I don't think that your issue can be solved at update rules because necsaary
informatiom is not provided there.
Structure G_S_MINFO is provided in <b>start routine of transfer rules (at least in 3.5.)</b>
At first please enhance datasource (to populate it for datapak) and comm structure with field/IO containing week and map it at the level of transfer rules to corresponding IO of IC .
BTW I detected a mistake in my coding ( table Datapak has no headerline, I forget it again and again).
Please add:
DATA : WA_TRASTRU TYPE TRANSFER_STRUCTURE.
Pleace replace loop-endloop block.
LOOP AT DATAPAK into WA_TRASTRU .
WA_TRASTRU -WW = Z_WW.
Modify DATAPAK from WA_TRASTRU .
ENDLOOP.
Hi Anima ,
You need to figure out how will you pass the exact file name as one instance of execution of infopackage to load file can have only one file name .
Are you going to input the file name in infopackage dynamically i.e. through a routine ??
If you use dynamic file name using routine in the infopackage then you can use the same logic in your update rule to pickup the filename . However first you should figure out how to pass the filename to infopackage and then only you can think of reading it in transformations .
Also you donot need to do open dataset to read the file when loading through an infopackage , you just need to give the file name .
Regards
Sanjay
User | Count |
---|---|
80 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.