2009 Nov 13 5:01 AM
Hi,
In my ALV output, I need to change the date format.
Presently in final table i am getting date in following format. 21.09.2009 but in output i need it in 21/09/2009.
Please suggest how to do it programitically. Date field
ls_fieldtab-tabname = 'IT_FINAL'.
ls_fieldtab-fieldname = 'SPTAG'.
ls_fieldtab-seltext_s = ls_fieldtab-seltext_m =
ls_fieldtab-seltext_l = 'Current Date'.
APPEND ls_fieldtab TO fieldtab.
CLEAR ls_fieldtab.
Distribution Channel :
2) In the output , the Distribution channel l should always appers as AS01. Hardcoded . Pls suggest how to do programitically.
ls_fieldtab-tabname = 'IT_FINAL'.
ls_fieldtab-fieldname = 'VTWEG'.
ls_fieldtab-seltext_s = ls_fieldtab-seltext_m =
ls_fieldtab-seltext_l = 'DIST. CHANNEL'.
APPEND ls_fieldtab TO fieldtab.
CLEAR ls_fieldtab.
Hi,
In my ALV output, I need to change the date format.
Presently in final table i am getting date in following format. 21.09.2009 but in output i need it in 21/09/2009.
Please suggest how to do it programitically. Date field
ls_fieldtab-tabname = 'IT_FINAL'.
ls_fieldtab-fieldname = 'SPTAG'.
ls_fieldtab-seltext_s = ls_fieldtab-seltext_m =
ls_fieldtab-seltext_l = 'Current Date'.
APPEND ls_fieldtab TO fieldtab.
CLEAR ls_fieldtab.
Distribution Channel :
2) In the output , the Distribution channel l should always appers as AS01. Hardcoded . Pls suggest how to do programitically.
ls_fieldtab-tabname = 'IT_FINAL'.
ls_fieldtab-fieldname = 'VTWEG'.
ls_fieldtab-seltext_s = ls_fieldtab-seltext_m =
ls_fieldtab-seltext_l = 'DIST. CHANNEL'.
APPEND ls_fieldtab TO fieldtab.
CLEAR ls_fieldtab.
2009 Nov 13 5:09 AM
Hi ,
when u make the final table , at that time u have to pass the constant value to vtweg field .
for date , u have to write a logic to change the format and pass the value to date field.
no need to change the field catalog.
for date , u do not refer field to standard dataelement . only refer to char10.
2009 Nov 13 6:08 AM
Hi ,
Try using this Function module .."CONVERT_DATE_TO_INTERNAL" for the date format conversion.
http://wiki.sdn.sap.com/wiki/display/Snippets/FUNCTIONMODULEFORCONVERTINGDATEINTOTHEGIVENFORMAT
Plz go through the above link .Hope it will be useful.
Thanks & Regards,
Rajasekhar.
2009 Nov 13 6:35 AM
Hi Kiro,
You can hardcode the date format as you required.
When you appedn this date field into Final table in the loop.
You can write this piece of code:
data: gd_date(10).
: Date type sy-datum.
: Date_format type SPTAG or Sy-datum.
Move SPTAG to another field...gd_date
gd_date = Wa_table-SPTAG.
Converts SAP date from 20.01.2001 to 01/09/2001
Date(2) = gd_date+6(2).
Date2(2) = gd_date4(2).
Date4(4) = gd_date2(4).
You can change the above code while checking in the debugger
CONCATENATE Date(2) '/' Date2(2) '/' Date4(4) INTO Date_Format.
wa_final-sptag = Date_format.
append wa_final to it_final.
Now pass it to the field catalog
The above code is just to give you an idea. You can change it accordingly in your scenario by using diff variables and concatenate into one variable and then pass it to the finalinternal table.
By doing this it will change the date format at the final internal table level and you will not have any issues displaying it.
This will resolve the issue.
You can also you the FM : SLS_MISC_CONVERT_TO_DATE
However, date format's usually displayed ina format in which youe SAP is configured.
https://wiki.sdn.sap.com/wiki/display/B1/ChangingtheFormatofaDateinaPrintLayoutDesign+Template
I see that you had posted same topic twice in this thread, it is not recomended.
If the issue is still not resolved , please paste your code here so that we will be able to assist you.
Regards,
Kittui
Edited by: Kittu on Nov 13, 2009 7:37 AM
Edited by: Kittu on Nov 13, 2009 7:44 AM
Edited by: Kittu on Nov 13, 2009 8:09 AM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |