‎2011 Sep 15 7:03 AM
Hi Experts,
I am stuck up with a little problem, i need your help
-
-
i am converting all the data types to CHAR but i am not getting the expected data out.........
My code is as below...where do i go wrong...
LOOP AT <T_ITAB> ASSIGNING <FIELD>.
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE <FIELD> TO <RECORD>.
IF SY-SUBRC = 0.
LV_FIELD = <RECORD>.
N = STRLEN( LV_FIELD ).
IF N = '8'.
IF LV_FIELD IS NOT INITIAL.
LV_DATE = LV_FIELD.
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
DATE = LV_DATE
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF SY-SUBRC EQ 0.
CONCATENATE LV_FIELD+6(2) LV_FIELD+4(2) LV_FIELD+0(4) INTO LV_FIELD SEPARATED BY '.'.
ENDIF.
ENDIF.
ENDIF.
IF LV_RECORD IS INITIAL.
LV_RECORD = LV_FIELD.
ELSE.
CONCATENATE LV_RECORD LV_FIELD INTO LV_RECORD SEPARATED BY ' * '.
ENDIF.
ELSE.
EXIT." DO
ENDIF.
ENDDO.
APPEND LV_RECORD TO LT_OUTPUT.
CLEAR LV_RECORD.
ENDLOOP.THE TABLE LT_OUTPUT LIKE THENV(CHAR 255)
My output looks some thing like this:
04 36876 15.09.2011 39600 1999
06 36960 15.09.2011 39600 2632
07 36874 15.09.2011 39541 9232
My expected output
04 36.876 15.09.2011 39.600 1.999
06 36.960 15.09.2011 39.600 2.632
07 36.874 15.09.2011 39.541 9.232
Regards
sam
‎2011 Sep 15 7:26 AM
Hi,
Please let us know the detail of one record in <T_ITAB>.
data type of LV_FIELD
Kesav
‎2011 Sep 15 7:49 AM
hi
thank u .............
field names of <T_ITAB> and data types:
TASKTYPE (raw) FIRSTRECT (dec) FIRSTRECDY (dats) LASTRECT (dec)
FIELD-SYMBOLS: <T_ITAB> TYPE ANY TABLE.
<RECORD> TYPE ANY,
<FIELD> TYPE ANY.
DATA: W_TABNAME TYPE W_TABNAME,
W_DREF TYPE REF TO DATA,
LV_FIELD TYPE STRING,
LV_RECORD TYPE STRING,
N TYPE I,
LV_DATE TYPE DATUM.
LV_FIELD TYPE STRING
regards
‎2011 Sep 15 7:51 AM
‎2011 Sep 15 8:00 AM
Hi,
at run time the data in the field symbol <T_ITAB> is
01 | 37136 | 20110915 | 39531 | 1039
02 | 36863 | 20110915 | 38709 | 3
03 | 36865 | 20110915 | 39600 | 49
thanks
‎2011 Sep 15 8:07 AM
Your problem is not with converting datatypes. The code you have written works correctly.
You records in <T_ITAB> doesnt have decimals for values of 2nd and 4 th field . How do you expect to have decimals by moving it to another variable ?
Hope you understood me.
Kesav
‎2011 Sep 15 8:17 AM
hi...
thanks for your quick reply....
At run time you can see all the data........ like what i have shown...
but if you clearly see, DATE will be in the internal format..but if you print it, it will be in dd:mm:yyyy
-
can you suggest me if i have a dynamic field symbol (table data) ,,,, How can i convert data types dynamically..
if it is a static internal table i am achieving with WRITE TO statement.....but i have huge data in field symbols...
any inputs ,really appreciated..
Thank u
‎2011 Sep 15 8:21 AM
At run time you can see all the data........ like what i have shown...
but if you clearly see, DATE will be in the internal format..but if you print it, it will be in dd:mm:yyyy
-
can you suggest me if i have a dynamic field symbol (table data) ,,,, How can i convert data types dynamically..
if it is a static internal table i am achieving with WRITE TO statement.....but i have huge data in field symbols...
Instead of all these , please specify the exact problem your are facing . What is it with date field ? . In SAP while printing the internal format will be converted to external. What is your requirement with this date field?
My output looks some thing like this:
04 36876 15.09.2011 39600 1999
06 36960 15.09.2011 39600 2632
07 36874 15.09.2011 39541 9232
My expected output
04 36.876 15.09.2011 39.600 1.999
06 36.960 15.09.2011 39.600 2.632
07 36.874 15.09.2011 39.541 9.232
I dont see any problems mentioned in your date field. Both your actual and expected outputs reflects the same in date field.
In SCN you will only get solutions if your question is precise.
Kesav
‎2011 Sep 15 8:40 AM
Hi,
thank u
my question is very simple....
i am executing a FM which will give me table data in internal tables....
now i wanna convert all the data types into CHAR..
since this FM is triggered by third party system....whic can understand only CHAR data type...
expected output:
Link: [Screenshot1|http://picturepush.com/public/6544689]
my output.........
Link: [Screenshot2|http://www5.picturepush.com/photo/a/6544688/640/6544688.jpeg]
thank u...........
sam
‎2011 Sep 15 9:23 AM
Still i am not clear withyour question.
now i wanna convert all the data types into CHAR..
You can use this example for this
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE lwa TO <fs>.
IF sy-subrc = 0.
DESCRIBE FIELD <fs> LENGTH lv_len IN BYTE MODE.
CREATE DATA wf_data TYPE c LENGTH lv_len.
ASSIGN wf_data->* TO <fs_str>.
<fs_str> = <fs>.
WRITE:/ <fs_str>.
ELSE.
EXIT.
ENDIF.
ENDDO.
‎2011 Sep 15 9:53 AM
hi Keshav
really that was a good reply...
but to be precise ....
as you can see in my code i am calling a FM 'DATE_CHECK_PLAUSIBILITY' which in fact pipes me the output as
required format(dd:mm:yyyy)... .if i am not calling that FM..,,the output is printed as (yyyymmdd)...
similarly, how can i achieve this for other data type (say RAW,PACKED.......)
moreover..i don't want to print it.....i want the data in an internal table..........
thanks and Regards
sam