Application Development and Automation 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: 
Read only

bdc using call transaction

Former Member
0 Likes
732

FORM validate_doj .

if it_emp-doj = 00000000 or it_emp-doj >= sy-datum or it_emp-doj = ' ' OR IT_EMP-DOJ CA '/'.

error_flag = 1.

it_errorrecds-it_emp_id = it_emp-e_id.

IT_ERRORRECDS-IT_DESC = 'INVALID DOJ'.

NOTE: INFORMATION IN THE FLAT FILE CONTAINS IN THE FOLLOWING FORMAT .21/12/2006 I.E. MM/DD/YYYY.

ABOVE CODE I AM USING FOR VALIDATING THE DATE.

BUT IT IS NOT TRAPPING THE ERROR,WHEN MONTH IS GREATER THAN 12.

FORMAT Of THE DATE WHICH I AM USING IS MM/DD/YYYY.

AND THE FOLLOWING IS THE RUN TIME ERROR WHICH I AM GETTING WHEN I EXECUTE MY TRANSACTION is :

" THE PROGRAM ATTEMPTED TO INTERPRET THE VAUE " 21/11/2005" AS A NUMBER ,BUT SINCE THE VALUE

CONTRAVENES THE RULES FOR CORRECT NUMBER FORMATS,THIS WAS NOT POSSIBLE.

well it is not trapping the error in my validations.

PLEASE PROVIDE ME WITH THE PROPER SOLUTION WHERE I CAN TRAP THIS ERROR IN MY VALIDATIONS.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
708

Hi Raghavendra,

You can use split function in the BDC program so that you can split the date into date, month and year.

Then you can do your validation process.

How to split the string?

Use the split function.

SPLIT text AT '/' INTO: str1 str2 str3.

For eg.


data: mm(2), dd(2), yyyy(4).
data str(30).

*str has the date.
str = '12/32/3443'.

SPLIT str AT '/' INTO: mm dd yyyy.
write: / mm, / dd, / yyyy.

hope it helps.

Kindly reward points if it helps by clicking the star on the left side of the screen.

Message was edited by: Maheswaran B

5 REPLIES 5
Read only

Former Member
0 Likes
708

hI Rahavendra,

what is the data type of it_emp-doj is it like sy-datum or some thing else(like char...)

Thanks

vijay

Read only

0 Likes
708

hai vijay!

its of type character.

Read only

0 Likes
708

since it is char,but you are comparing this...

<b>it_emp-doj >= sy-datum</b> with date.

obviously it will give dump...

convert that to date and check...

vijay

Read only

Former Member
0 Likes
708

Hi raghavendra,

1. CONVERT_DATE_TO_INTERN_FORMAT

Use the following FM

to check any Date.

In parameter DTYPE pass 'DATS'

2. Please do not use any of your own logic

like checking /, date+4 etc.

SAP Recommends to use the standard FMs

to perform any check or calculations.

regards,

amit m.

Message was edited by: Amit Mittal

Read only

Former Member
0 Likes
709

Hi Raghavendra,

You can use split function in the BDC program so that you can split the date into date, month and year.

Then you can do your validation process.

How to split the string?

Use the split function.

SPLIT text AT '/' INTO: str1 str2 str3.

For eg.


data: mm(2), dd(2), yyyy(4).
data str(30).

*str has the date.
str = '12/32/3443'.

SPLIT str AT '/' INTO: mm dd yyyy.
write: / mm, / dd, / yyyy.

hope it helps.

Kindly reward points if it helps by clicking the star on the left side of the screen.

Message was edited by: Maheswaran B