‎2006 Dec 28 8:36 AM
Hi All,
I have to write the Conversion Routines and Transformation Process for below Fields,
I have a situation, where am having text files with the data having below fields, and before uploading the data to Database i have to do conversion.
So anybody Plz help me regarding this conversion topic how to write the process and how to write the code.
Table Field Name Type Length Short Text
BKPF BLART CHAR 2 Document Type
BKPF BUKRS CHAR 4 Company Code
BSEG BUKRS CHAR 4 Company Code
BSEG HKONT CHAR 10 General Ledger Account
BSEG KOSTL CHAR 10 Cost Center
BSEG VERTN CHAR 13 Contract Number
KNA1 KUNNR CHAR 10 Customer Number
‎2006 Dec 28 8:54 AM
1. You know the fields which are coming from text file.
define an internal table with same structure as text file record.
1. you have to upload the data from text file.
use FM 'ws_upload', this will read all the records into internal table ITAB.
2. loop into internal table, use CONVERSION_EXIT_ALPHA_INPUT and modify the table.
e.g.:-
loop at ITAB.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ITAB-kunnr
IMPORTING
output = ITAB-kunnr.
...
do the same for other fields.
*modify the internal table with new values.
modify ITAB.-kunnr transporting kunnr.
endloop.
‎2006 Dec 28 8:39 AM
No need to write, you already have alpha. use the existing one.
e.g.:-
loop at lt_kunnr.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lt_kunnr-kunnr
IMPORTING
output = lt_kunnr-kunnr.
modify lt_kunnr-kunnr transporting kunnr.
endloop.
‎2006 Dec 28 8:45 AM
‎2006 Dec 28 8:52 AM
‎2006 Dec 28 8:54 AM
1. You know the fields which are coming from text file.
define an internal table with same structure as text file record.
1. you have to upload the data from text file.
use FM 'ws_upload', this will read all the records into internal table ITAB.
2. loop into internal table, use CONVERSION_EXIT_ALPHA_INPUT and modify the table.
e.g.:-
loop at ITAB.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ITAB-kunnr
IMPORTING
output = ITAB-kunnr.
...
do the same for other fields.
*modify the internal table with new values.
modify ITAB.-kunnr transporting kunnr.
endloop.
‎2006 Dec 28 9:03 AM
Hi all again,
Can i use this function module('CONVERSION_EXIT_ALPHA_INPUT') for all the fields for conversion.
BALU.
‎2006 Dec 28 9:09 AM
Yes you have to use that FM 'CONVERSION_EXIT_ALPHA_INPUT'
1. if your value is 234 and the field is of character 5 ,
after using 'CONVERSION_EXIT_ALPHA_INPUT' that value will become 00234
2. If ur value is 00234 and if u use 'CONVERSION_EXIT_ALPHA_OUTPUT' ur value will be 234
‎2006 Dec 28 9:13 AM
Hi Bala
Supposing all the fields exist in internal table itab. You can add the code simple as below:
loop at itab.
.....
perform conv_fld changing: itab-bukrs,
itab-blart,
itab-hkont,
itab-kostl,
itab-vertn,
itab-kunnr.
.....
.....
endloop.
*&---------------------------------------------------------------------*
*& Form conv_fld
*&---------------------------------------------------------------------*
FORM conv_fld CHANGING fld.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = fld
IMPORTING
OUTPUT = fld.
ENDFORM. " conv_fldSo for each field depending on its length the conversion routine acts and gives the right output. Please make sure, that your internal table if defined with the right field references or length.
Kind Regards
Eswar
‎2006 Dec 28 9:16 AM
Hi Chandrasekhar Jagarlamudi ,
How can i use this function module for Document type and company code ,
my requirement is that i have to do conversion for all those fields,
and before doing the coding part for this Plz tell me the transformation process for all these fields.
BALU.
‎2006 Dec 28 9:18 AM
Hi Bala chandar,
Ther is no need of Conversion routines for Document types and Company codes as they will be completely filled with its full length
‎2006 Dec 28 9:22 AM
Hi Eswar Rao,
Thnk u for ur response,
Plz Tell me the transformation process for all these fields,
give me the documentation for this if possible.
BALU.
‎2006 Dec 28 9:27 AM
Am not sure what you mean by transformation process. Can you be more specific...
Kind Regards
Eswar
‎2006 Dec 28 9:29 AM
Hi Eswar,
Go through below,
All dates in format MM/DD/YYYY
All times should be in format HH:MM:SS
Currency should be in format xxxxxxx.xx (without comma separation).
Quantity should be in format xxxxxxx.xxx (without comma separation).
So like this i have to write the Transformation process, could u plz help me in this.
BALU.
‎2006 Dec 28 9:37 AM
Hi Bala
For this, check the format of data that is coming in the file and then manipulate accordingly. This can vary for company to company, hence will not be generic. So proceed as per the info below:
If the format for date is yyyymmdd.
Define a variable of type char and length 10. Eg: for_date(10) type c.
ITAB has field DATE to hold the date coming from file then do like this:
concantenate itab-date4(2) itab-date6(2) itab(4) into for_date separated by '/'.
Now for_date will have the format MM/DD/YYYY.
Similary you can handle for Time.
For currency, declare a char variable for required lenght. Move the value to char. So the formatting option like COMMA will disappear.
Hope this helps.
Kind Regards
Eswar
‎2006 Dec 28 9:50 AM
Thank u Eswar,
I have mentioned some fields na, for those fields i have to take conversion part,
i am extracting the data from BKPF and BSEG table and using Gui_Download FM am creating text files, in those text fiels am extracting the data for all these fields and now the files are ready for conversion. And to convert, the fields are those i had mentioned before.
So in the code where i have to mention these conversion coding part.
BALU.
‎2006 Dec 28 9:59 AM
Hi Eswar,
Could u plz help me.
Go through below.
I have mentioned some fields na, for those fields i have to take conversion part,
i am extracting the data from BKPF and BSEG table and using Gui_Download FM am creating text files, in those text fiels am extracting the data for all these fields and now the files are ready for conversion. And to convert, the fields are those i had mentioned before.
So in the code where i have to mention these conversion coding part.
BALU.
‎2006 Dec 28 10:15 AM
‎2006 Dec 28 10:17 AM
HI Bala
Seems i have lost.
As per my understanding, you are extracting data from tables BKPF and BSEG to an internal table.
Now you are downloading the data as text files using FM: GUI_DOWNLOAD.
So in this case, you dont need the other conversions. I guess you just need to re-format the data for Date and Time.
Please correct me if my understanding is wrong.
Kind Regards
Eswar
‎2006 Dec 28 10:19 AM
No Eswar,
I have to do conversion for those fields i have mentioned.
BALU.
‎2006 Dec 28 10:29 AM
‎2006 Dec 28 10:55 AM
Hi ,
Actually am doing the comparison for two text files,
first am going to create one text file1 using GUI_download and after that i am going to create another text file2 using GUI_download .
now i have to do conversion for those fileds i had mentioned , that is for old values(file1) and new values(file2).
Help me.
BALU.
‎2006 Dec 28 12:04 PM
Bala
Can you post your code, maybe that can help for some understanding.
Regards
Eswar