Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Date Feild(acc to user settings) in Dynamic columns(length is not adjusting correctly)

Former Member
0 Kudos

HI Folks,

how to make the date field according to user settings(char10 with spl characters YYYY/MM/DD) in dynamic columns display.

since when I am trying to chagne the field from char8 to char10 it is still taking the defualt value of the field(dats 😎 and it is displayin as YY/MM/DD.

my sample code is

c_msdv is field from MARA-MSTDV.

*****************

         g_flname = c_msdv.

         MOVE:w_out-mstdv TO g_fieldvalue.

*        CONDENSE    g_fieldvalue NO-GAPS.
         ASSIGN COMPONENT  g_flname
             OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
         <fs_fldval> =  g_fieldvalue.
         CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'
           EXPORTING
             input  = <fs_fldval>
           IMPORTING
             output = <fs_fldval>.

<fs_fldval> is becoming char, is ther any way i can change it to char10 i guess then i will get the correct value.

Please help me .

Thanks,

Shwetha

Message was edited by: Suhas Saha

8 REPLIES 8

Private_Member_49934
Contributor
0 Kudos

You cannot dynamically change the data type <fs_fldval> is your case is still date field stored internally as char8 what you can do is create an additional field of char 10 and write w_out-mstdv to say w_out-mstdv_10.

Btw. Always do sy-subrc check after assigning to a field sysmbol

0 Kudos

Hi Gaurav ,

Thanks for your quick response.

But after i moved the field vlaue ot char 10 field then also same

even i change  this  g_flname = 'KUNNR'(some char10 field), instead of    g_flname = c_msdv..

then also <fs_fldvalue> is char 8 . I am not getting from where this <fs_fldvalue> is getting char8 value.

Please help me on this issue.

Thanks,

Neelima N

0 Kudos

Can you post your code as text file. It will easier to understand the context

0 Kudos

Hi Gaurav,

Please find the attached my sample code.

Please do needful

Thanks

Shwetha

SuhaSaha
Advisor
Advisor
0 Kudos

Hello Sweta,

You can utilise RTTI classes to identify the runtime type of the data object & modify it according. A sample example is provided below:

   DATA: g_date          TYPE datum,
      g_dt_ext_format TYPE char10,
      go_typedescr    TYPE REF TO cl_abap_typedescr.

FIELD-SYMBOLS <g_value> TYPE ANY.

g_date = sy-datum.

ASSIGN g_date TO <g_value>.

IF <g_value> IS ASSIGNED.
* Get the runtime details of the data variable
  go_typedescr = cl_abap_typedescr=>describe_by_data( <g_value> ).

* Check if the variable contains date
  IF go_typedescr->type_kind = cl_abap_typedescr=>typekind_date.

*   Convert from internal SAP format to User format
    WRITE <g_value> TO g_dt_ext_format. UNASSIGN <g_value>.
    WRITE g_dt_ext_format. CLEAR g_dt_ext_format.
  ENDIF.
ENDIF.

Btw, what is the type of the field-symbol: <fs_fldval>? And what technique are you using to output the dynamic internal table?

BR,

Suhas

Private_Member_49934
Contributor
0 Kudos

I got your problem perhaps. I see a lot of unnecessary code out there in your progrm.

My observations y

1) you are pouplating  t_fs_fldcat and you are creating dynamic table with field catalog

  cl_alv_table_create=>create_dynamic_table.

2) you are pouplating data from table to this dynamic table

3) you are using a lot of formating exit routines to get the dat formatted correctly which are NOT required.

Solution. Create the field catalog with proper fieldcat-rollname. The data type will be created correctly and formating will be automatic. Right now your all field are char only. Try this and let me know

0 Kudos

HI All,

Thanks for all your inputs.

after changing the field catlog of that field length to 10. it is working fine.

Thanks everybody,

Shwetha

0 Kudos

Glad that it helped. It's always helpful to others in future if you mark the helpful / correct answer and chnge the status of the thread.