cancel
Showing results for 
Search instead for 
Did you mean: 

Add Item # to Date

Former Member
0 Kudos
72

Hello Friends please help me with the code or Formula syntax in Transformaton ,. I want to add the Item # to the date field

Example Item # FIELD = 10

Date is = 10/2/09

So after ADD ITEM# TO DATE IT SHALL BE 10/12/09

Thanks

Soniya

Accepted Solutions (1)

Accepted Solutions (1)

dennis_scoville4
Active Contributor
0 Kudos

If you're trying to add some number of days to a date, which is what it looks like you're trying to do:


CONSTANTS: c_10(2) TYPE n VALUE 10.

date_field = date_field + c10.

This will take whatever the date was, in your example 2-Oct-2009, and add 10 days to it so that it's 12-Oct-2009. I'm assuming that you're using MM/DD/YYYY format for your example.

Edited by: Dennis Scoville on Nov 16, 2009 12:44 PM

Former Member
0 Kudos

Hello Dennis Thanks for the help, however my Addition is dynamic so I want the field Item Number date_field = date_field + Itemnum but it does not work. can u tell me the code how to make this dynamic addition

Thanks

soniya

dennis_scoville4
Active Contributor
0 Kudos

To make it dynamic, your going to have to have somewhere in your code that derives/determines what the value of itemnum should be. What we did, and it's a highly recommended way to go, is create a TVARV-like table that can be read for things like this, where we change the parameters when/if needed.

Then, in the Transformation routine, you'll have to do a SELECT on this TVARV-like table to get the value you want to put into itemnum for calculating the new date.


CONSTANTS: c_itemnum TYPE rvari_vnam VALUE 'ITEMNUM'.

DATA: l_itemnum(3) TYPE n.

SELECT
   low
FROM
  zvarv
INTO
  l_itemnum
WHERE
  name EQ c_itemnum.

date_field = date_field + itemnum.

If the itemnum value is based on a condition, then instead of selecting from the table, just perform the IF...ELSE...ENDIF or CASE...WHEN...ENDCASE. statement to determine the value, and calculate date_field as shown.

Answers (0)