How to check data type of the field symbol at run time

Hi,
My code is as following:
      LOOP AT <fs> ASSIGNING <wa_covp_ext>.
        ASSIGN COMPONENT 86 OF STRUCTURE <wa_covp_ext> TO <f_zzname>.
        IF sy-subrc = 0.
          ASSIGN COMPONENT 158 OF STRUCTURE <wa_covp_ext> TO <f_pernr>.
          IF sy-subrc = 0.
              SELECT SINGLE sname INTO <f_zzname> FROM pa0001
                            WHERE pernr = <f_pernr>
                            AND endda GE sy-datum
                            AND begda LE sy-datum.
         ENDIF.
      ENDIF.
    ENDLOOP.
This query is giving dump when <f_zzname> is type P length 8 and decimals 2, because it tries to put PA0001-sname into it which is type C length 30. So I want to check the type of <f_zzname> before the select statement. If it is character 30, then I will write the select statement else not.
How to check data type of the field symbol at run time? If it's not possible, then can somebody suggest a workaround? Thanks.

check this ...
write describe statement  ...
field-symbols : <f_zzname> .
data : sname like pa0001-sname,
       typ(10).
assign sname to  <f_zzname>.
describe  field <f_zzname> type typ.
write : typ. <-- typ contains character type in this case ..
U can check if typ is of character(C) if so .. write the select statement ...

Similar Messages

  • How to Find the Data Type of the Field In a Database Table

    Hi Experts,
    I'm currently working on a program which needs to find out the data type of the given field in a database table. In addition to accessing DD03L directly, is there any other workaround such as function module to help me achieve this? It would be helpful if a demo example could be provided.
    Thanks a lot.

    Hi,
    Use this..
    DESCRIBE FIELD dobj  TYPE typ.
    write typ.
    type will contain the data type of the object.
    and check this thread also....
    Re: How to get datatype of fields in dynamic structures
    Cheers,
    Simha.
    Reward all the helpful answers..

  • How to change data type for a field?

    Hi Experts,
    I have one std screen having one field having numeric type. So it will accept only numeric value. Remember I am using standard transaction.
    Now my user wants to enter the special character like + or - in that field(having data type numeric).
    How i can change the data type for the particular field  so that it will also accept + or -?
    Plz reply me as earliest as possible.
    Thanks in advance.

    Hi salil ,
    u have to change / create Domain of  that Data Element.
    but u have to check the Implications. i have done the same thing , but that one is Customer defined one , i got nearly 20 short dumps while doing the TP.
    regards
    Prabhu

  • How to display dates on which the field of an infotype is changed

    there are two fields   in an infotype and both the fields are changed on different dates then how to display those dates on which the two fields are changed

    Hi ankit,
    If you want the change log for one infotype with one two fields, then write one custom program with following logic. If you want the log for multiple infotypes for multiple fileds then you have to use that program 'RPUAUD00'. Read the documentation of the program to check how to use it.
    select * from pa0000 into table it_pa0000
                                   where pernr = v_pernr.
    sort it_pa0000 by begda descending.
    loop at it_pa0000 into wa_pa0000.
    write your own logic to compare the previous record PERSG with current record PERSG.
    if this doesnt match then get the Changed DATE from AEDTM field.
    wa_pa0000-AEDTM = changed date.
    Else.
    continue with loop.
    exit.
    endloop.
    regards,
    Shrinivas

  • How To... Change the Data Type for a SELECT-OPTIONS at run time.

    Hello,
    I am trying to restrict the values available for entry into a SELECT-OPTIONS at run time depending on user input.
    The logic is as follows. The user has two input fields. A PARAMETER field which has the type RSDIOBJNM and allows them to choose an InfoObject. And the user has a SELECT-OPTIONS field to allow them to select the Characteristic values for that InfoObject.
    I would like the following example to be possible:
    The user enters 0MATERIAL into the PARAMETER. When the user clicks on the SELECT-OPTIONS control code will derive a list of possible options the user can enter in the SELECT-OPTIONS. In this case only values found in the master data or at least no values greater than 18 characters.
    I have looked at the following function module SELECT_OPTIONS_RESTRICT and this do not appear to be helpful as they only restrict on the signs allowed for the values (unless I misunderstand, it is a complex function module!).
    The code I have so far is (thus the user enters a InfoObject into p_char1 and the select options so_char1 should only accept active values of that InfoObject):
    declaration of variables for user interface
      DATA c_char(32) TYPE c.
    declaration of count variable
      DATA i_count TYPE i.
    declaration of user interface
      SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
        PARAMETERS: p_ipack TYPE RSLOGDPID.
      SELECTION-SCREEN END OF BLOCK a1.
      SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.
        PARAMETERS: p_char1 TYPE RSDIOBJNM.
        SELECT-OPTIONS: so_char1  for c_char NO INTERVALS.
        PARAMETERS: p_char2 TYPE RSDIOBJNM.
        SELECT-OPTIONS: so_char2  for c_char NO INTERVALS.
        PARAMETERS: p_char3 TYPE RSDIOBJNM.
        SELECT-OPTIONS: so_char3  for c_char NO INTERVALS.
      SELECTION-SCREEN END OF BLOCK b1.
    Is what I am trying to do possible???
    Thanks for any help. Ross.

    You really want to restrict possible values of a select-option based on another field, not change the length of type of the select-option field, right?
    Here is what you do:  Code a custom F4 value help for the select-option at event AT SELECTION-SCREEN ON VALUE REQUEST FOR..  The first thing you do here is read the value of the parameter field (p_ipack in your example).  You can use function module DYNP_VALUES_READ.  Based on this value, you can propose values for the select-option fields.  Note that the use can still enter whatever s(he) wishes in to the select-option field without pressing F4. In this case, you will have to code some input validations taking into account the value in the p_ipack field.

  • Rfc--- jdbc, how to define data types for the rfc's

    i downloaded the rfc.xsd in to local hard drive. while i am defining the data type i am getting an error. do i have to change any thing the rfc.sxd file please help me
    thanks

    Hi there,
    How did you load the RFC metadata from the SAP system? I assume you are using the standard procedure via your Software component in the (Design)integration builder-Repository your namespace- > imported Objects -> RFC/IDOCS.
    From there after you have entered the necessary details for the SAP system where the RFC exists; you can select from a list the BAPI/RFC you need in your interface.
    Cheers,
    Roberto
    PS: Look at the below link for more information how to do that:
    http://help.sap.com/saphelp_nw04/helpdata/en/d3/35da4105aa3f5de10000000a1550b0/frameset.htm
    Message was edited by: Roberto Viana
    Message was edited by: Roberto Viana

  • How to dynamically assign type to a field-symbol?

    Hi,
    I have two fields in one table, one for field name and one for table name.  These can be fields in different
    tables. I need to fetch value of this field in that table. So the type of this variable can change dynamically.
    I am trying to assign type of this field dynamically to a field-symbol. I have to use this field symbol in a
    select statement.  Currently it is showing a dumb, as the field type is dec7.  For some other types it is
    working fine.
    Regards,
    Sunil

    Hi all,
    I have the same problem.
    I tried with your helps but i can't fix them.
    A message is raised "Field <fs_bet> unknown" when i used code below
    FIELD-SYMBOLS: <fs_bet> TYPE any.
    DATA: c_bet TYPE string.
    DATA it_0008 type STANDARD TABLE OF pa0008 WITH HEADER LINE.
    DO 40 TIMES.
      CONCATENATE 'BET0' index into c_bet.
      ASSIGN (c_bet) to <fs_bet> CASTING TYPE pad_amt7s  .
      select * from pa0008 into it_0008
         where <fs_bet> = '1000'
         and pernr = 32.
         append it_0008.
      ENDSELECT.
    ENDDO.
    Please help me to solve it.
    Thanks so much,
    Sophie Tran

  • How do i get the data present in the selected row at run time in Multicolumn list box?

    Hi,
    I am using multicolumn list box with three columns and i am having OK button.
    If the user selects particular row and then press ok then that row datas(that 3 values) has to get update in the file.
    Can u tell me how to get that selected row values alone and also how to append the list box value at run time?
    Thanks
    Meenatchi

    You can simply use the Value property of the MLBox to get the row selected & wire it to the Delete from array function with the Itemnames of the MLBox as the Input & Output of the Delate from array function.
    See the attached VI.
    - Partha
    LabVIEW - Wires that catch bugs!
    Attachments:
    Dbl-click Row to get Data & Delete.vi ‏41 KB

  • How to check date type is initial

    there is SQL sentence.
    DATA: BEGIN OF it OCCURS 0,
        matnr LIKE mara-matnr,
        laeda  LIKE mara-laeda,
      END OF it.
    select matnr laeda
    from mara
    where laeda <> space.
    How can I  check the  laead field is initial.
    Regards.

    Hi,
         Try this syntax
    SELECT... WHERE s IS [NOT] NULL...
    SELECT matnr laeda FROM mara INTOTABLE it_itab WHERE
    laeda IS [NOT] NULL.
    Regards
    Bala Krishna

  • SQL - How to check data type definition

    Is it possible to check (inside SQL statement) how particular field is defined. Is it VARCHAR2(5) or VARCHAR2(10)

    If by field you mean column, then use USER_TAB_COLUMNS, ALL_TAB_COLUMNS or DBA_TAB_COLUMNS:
    SELECT  TABLE_NAME || '.' || COLUMN_NAME || ' ' || DATA_TYPE ||
            CASE
              WHEN DATA_TYPE LIKE '%CHAR%' THEN '(' || DATA_LENGTH || ')'
              WHEN DATA_TYPE = 'NUMBER' THEN '(' || DATA_PRECISION  || ',' || DATA_SCALE || ')'
            END X
      FROM  USER_TAB_COLUMNS
      WHERE TABLE_NAME = 'EMP'
      ORDER BY COLUMN_ID
    X
    EMP.EMPNO NUMBER(4,0)
    EMP.ENAME VARCHAR2(10)
    EMP.JOB VARCHAR2(9)
    EMP.MGR NUMBER(4,0)
    EMP.HIREDATE DATE
    EMP.SAL NUMBER(7,2)
    EMP.COMM NUMBER(7,2)
    EMP.DEPTNO NUMBER(2,0)
    8 rows selected.
    SQL>   SY.

  • How to change the data type in the table ESLL for the field USERF2_NUM ?

    Hello Friends,
    I have a requirement in which one of the change is to convert the data type of the field 'USERF2_NUM' in the table 'ESLL'  from 'QUAN' to 'CHAR'. 
    How do i do it if i have an access to change it..........i think i should also check the impact of the change if done.
    Kindly tell me as my requirement starts with this small change.
    Regards,
    Rajesh Kumar

    Thanks for the reply Sowmya.
    I would like to know 2 things.
    1. Is it ok to change the data type of the field 'USERF2_NUM '  which is in the table ESLL. from quan to char.
    2.  The table ESLL  already has entries. if we change the data type from QUAN to CHAR what is the  effect on the existing entries of the table .
    Kindly reply me back.
    Thanks & Regards,
    Rajesh Kumar

  • Can we change the data type of a field based on the value of the field

    HI Gurus,
    My Requirement is as below -- Could you please guide me
    in the Printable Adobe form -- for ex - as usual for dates fields in the Object Pallette the object type is a date/time field  and for quantity/currency fields corresponding fields are taken
    now in case the either the date, quantity or currency is initial in place of displaying 0.00 or empty date we need to display N/A (Not Applicable)
    for this I would like to change the data type of the field
    to put it simply --
    we need to change the data type of date field from DATE&TIME to Char type to hold N/A or  Quantity field to Char field to hold N/A
    how can we realize this in SAP adobe forms
    Thanks in Advace
    Ramchander Rao.K

    Hello Ramchander,
         You cannot change the data type of the field at run time in Adobe forms because the type of field you choose at the time of design level is associated with the data type itself.
    If you want to achieve your requirement, then your main idea should be to set the data type as CHARACTER itself while designing the field in the adobe form itself. CHAR field will comfortably hold the value of Calculation/amount field, Currency field, Amount, Date, Time HHMMSS, Unit Accuracy, Currency key, Floating point number, Numeric text, Client, Language and many other data types.
    After designing the field as TEXT field in Adobe form you have two options.
    Option 1:
    Select the Date field initially as type TEXT field or CHAR field in Adobe forms.
    Suppose the name of the field is TEXTFIELD1, then write the Javascript code on this field in Initialize event as below.
    if ( this.rawvalue == null )
         this.rawvalue = "N/A";
    If the field is not blank, then it will show the date. Else it will show "N/A".
    Option 2:
    Select the Date field initially as type TEXT field or CHAR field in Adobe forms. Do the formatting part in ABAP itself. It will increase the performance. Avoid Javascript as much as possible.
    Suppose you have a DATE variable l_dats of type DATS. Then take another variable l_date of type CHAR. Then write the below ABAP code.
    MOVE l_dats TO l_date.
    IF l_date IS INITIAL.
         l_date = 'N/A'.
    ENDIF.
    Bind the l_date to the TEXT field in the form.
    Even in this case, if the field is not blank, then it will show the date. Else it will show "N/A".
    But I will suggest you to use Option 2 of keeping the AMOUNT, QUANTITY, DATE, TIME fields etc as CHAR or TEXT fields in Adobe form and do the required formatting in ABAP itself.

  • How to find data type of field dynamically in abap

    hi all,
    I am hanged up in one issue. There an internal table is filled.
    theres one field ,and  i want to extract the data type of the field content.
    Ex. i_tab is internal table having field var1.
          let the content of var1  have data type same as that of matnr (material no.)
    so here i want to extract this data type.
    thanx in advance for efficient help

    hi,
    Use the statemnt
    DESCRIBE FIELD 
    Use the edition   TYPE typ [COMPONENTS com]
    More help use F1
    example fropm F1 help
    DATA: BEGIN OF struc1,
            comp1 TYPE c LENGTH 1,
            comp2 TYPE string,
            BEGIN OF struc2,
               comp1 TYPE c LENGTH 1,
              comp2 TYPE i,
            END OF struc2,
          END OF struc1,
          typ1  TYPE c LENGTH 1,
          comp1 TYPE i,
          typ2  TYPE c LENGTH 1,
          comp2 TYPE i.
    DESCRIBE FIELD: struc1        TYPE typ1 COMPONENTS comp1,
                    struc1-struc2 TYPE typ2 COMPONENTS comp2.
    regards
    prasanth

  • How to change the Field Symbol, so Adobe Forms takes it as a Table?

    Hi guys,
    I created an Field Symbol, in a Interface which I use for Adobe Forms. The type of the Field Symbol is STANDARD TABLE, and this field symbol I fill with data from another program.
    But the problem is that in adobe forms, this Field Symbol is taken as TEXT FIELD and not as Table... and this shows me a Dump because it can't convert Internal Table to type C (the dump is like that).
    What I need, is how to change the Field Symbol, so Adobe Forms takes it as a Table?
    I looked at Adobe Form, and found this:
    The Type Category of the Field Symbol is DICTIONARY TYPE and I think I need to change it to Internal Table as shown in the right picture.
    Does someone have any idea?

    Hello Taly,
    To what i understand your requirement, you need to pass data from Field symbol to internal table in Adobe form.
    You have done it correct partially. I have replicated your scenario and steps are below -
    1) Create a Z structure
    2) Create Z Table Type
    3) Create Adobe Interface with Table & Field Symbol. Also do coding as shown to assign the internal table populated in driver program to filed symbol.
    4) Design Form as -
    5) Code driver as -
    *& Report  ZR_AF_FS_1
    REPORT  zr_af_fs_1.
    DATA: fm_name           TYPE rs38l_fnam,
           fp_docparams      TYPE sfpdocparams,
           fp_outputparams   TYPE sfpoutputparams,
           it_kna1           TYPE ztt_fs_1.
    * Sets the output parameters and opens the spool job
    CALL FUNCTION 'FP_JOB_OPEN'                   "& Form Processing: Call Form
       CHANGING
         ie_outputparams = fp_outputparams
       EXCEPTIONS
         cancel          = 1
         usage_error     = 2
         system_error    = 3
         internal_error  = 4
         OTHERS          = 5.
    IF sy-subrc <> 0.
    *            <error handling>
    ENDIF.
    *&---- Get the name of the generated function module
    CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'           "& Form Processing Generation
       EXPORTING
         i_name     = 'ZAF_FS_1'
       IMPORTING
         e_funcname = fm_name.
    IF sy-subrc <> 0.
    *  <error handling>
    ENDIF.
    *-- Fetch the Data and store it in the Internal Table
    SELECT kunnr name1 name2 adrnr FROM kna1 INTO TABLE it_kna1 UP TO 15 ROWS.
    * Language and country setting (here US as an example)
    fp_docparams-langu   = 'E'.
    fp_docparams-country = 'US'.
    *&--- Call the generated function module
    CALL FUNCTION fm_name
       EXPORTING
         /1bcdwb/docparams        = fp_docparams
          it_data                   = it_kna1
    *    IMPORTING
    *     /1BCDWB/FORMOUTPUT       =
       EXCEPTIONS
         usage_error           = 1
         system_error          = 2
         internal_error           = 3.
    IF sy-subrc <> 0.
    *  <error handling>
    ENDIF.
    *&---- Close the spool job
    CALL FUNCTION 'FP_JOB_CLOSE'
    *    IMPORTING
    *     E_RESULT             =
       EXCEPTIONS
         usage_error           = 1
         system_error          = 2
         internal_error        = 3
         OTHERS               = 4.
    IF sy-subrc <> 0.
    *            <error handling>
    ENDIF.
    6) Output -
    BR.

  • How to coerce data types to strings in a SELECT statement?

    ABAPers,
    I need to coerce column outputs to strings in a SELECT statement. Here is a pseudo example:
    select ConvertToString(count(*)) from MARA
    On help.sap.com, I could not find enough information on the functions that are supported within SELECT statement. I would appreciate it if someone can enlighten me on how to achive this.
    Note that my real problem is that I do not know the return type of the specified columns. The columns are passed as a user-specified parameter. As I do not know the column types, I am mandating that customers specify columns that return only string type data.
    Thank you in advance for your help.
    Pradeep

    Hi Pradeep,
    Convert to string wont be possible in the SELECT statement.
    What you can do is use Field Symbols. This allows to assign data types dynamically.
    Field-Symbols
    Best regards,
    Prashant
    Pls. mark points for helpful answers

Maybe you are looking for