cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos
1,562

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

View Entire Topic
pavan_prabhu
Active Participant
0 Kudos

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.