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: 

PLz help me, Its URGENT WORK

Former Member
0 Kudos

Hi all,

In My flat file contains data

Cost center|Posting Date|transaction date

In our flat file contains

Cost center|Posting Date|transaction date|D/C|

z456 | /05/2005 |5/6/2005 |'D

y789 |8/9/2005 |4/5/2005 |C

iam uploding the data into table ITAB

Error - ITABE

Sucess- ITABS

once upload data into ITAB

loop at itab

Here i want validations

Error dates are stored in ITABE ' /05/2005'

Error cost center stored in z456 & y789

Error D/C stored in 'D

How to validate and stored in the ERROR ITAB

Please send the Guide lines or logic

I look forward to your reply

Advanced thanks to them

Regards

Raja Sekhar.T

13 REPLIES 13

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Just try like this.

Loop at itab into wa .

if ( cost_center = 'Z456' or cost_center = 'Y789' ) and posting_date = '/05/2005' and D/C = 'D'.

move-corresponding wa to wa_e.

append lines of wa_e to itabe.

elseif.

move-corresponding wa to wa_s.

append lines of wa_s to itabs.

endif.

endloop.

If any one satisfies,error should happen

Change the if statement as using OR

if ( cost_center = 'Z456' or cost_center = 'Y789' ) or posting_date = '/05/2005' or D/C = 'D'.

move-corresponding wa to wa_e.

append lines of wa_e to itabe.

elseif.

move-corresponding wa to wa_s.

append lines of wa_s to itabs.

endif.

Kindly reward points by clicking the star on the left of reply,if it helps.

0 Kudos

Hi Jayanthi Jayaraman ,

Thank u for your reply

My quries is

COST CENTER Contains only numiric like 11250

suppose miss typed in cost center like z456 is error record

Same for the Dates: error handling if the format of the date is not correct. (eg. Blanks before the dates)

Please help me logic or guide lines

I look forward to your reply

Advanced tahnks to your reply

Regards

Raja Sekhar.T

0 Kudos

HI,

for cost center you can check against csks table

select singel kostl from csks where kostl = itab-kostl.

if not sy-subrc is intial.

move to error tab

endif

or simply

data n1(10) type n

n1 = itab-kostl

if n1 <> itab-kostl.

move to error

endif

cheers,

sasi

0 Kudos

Hi sasikumar palanichamy

Thank u for ur reply

Using the blow code the system goes to dump

data n1(10) type n

n1 = itab-kostl

if n1 <> itab-kostl.

move to error

endif

Please check and send me

Advanced tahnks for your reply

I look forward to your reply

Regards

Raja Sekhar.T

0 Kudos

Even if it passes a check for all numeric characters, you should still check it against the table. So, it would be easier just to hit the table with the value, then you no its correct with one check.

select singel kostl from csks where kostl = itab-kostl.
if not sy-subrc is intial.
* Error
endif.

But if you still want to check for all numeric characters. You can do this.

data: kostl(10) type c value 'Z465'.

if kostl CN '0123456789'.
  write:/ 'This is not a valid cost center'.
endif.

Regards,

Rich Heilman

0 Kudos

hi,

sorry that's the mismatch in type

data n1(10) type n.

data : c1(10) type c value 'a100001',

c2(10) type c.

n1 = c1.

c2 = n1.

if c2 <> c1.

write 'x'.

endif.

this the shortcut method, i give alternate solution also which is the correct one

cheers

sasi

0 Kudos

Hi Rich Heilman,

Thanks for your reply

iam sending the code please correct the validations

DATA ITAB LIKE ZPCARD1 OCCURS 100 WITH HEADER LINE. - flat file data

DATA ITABS LIKE ZPCARD1 OCCURS 100 WITH HEADER LINE.-Sucess data

DATA ITABERR LIKE ZPCARD1 OCCURS 100 WITH HEADER LINE.-Error data

DATA ITABV LIKE tcurc OCCURS 100 WITH HEADER LINE.

select * from tcurc into table itabv.

sort itab by inter_audit_cd txn_dt posting_dt.

loop at itab.

if ITAB-inter_audit_cd is initial.

message I000(zcardmesg).

stop.

ELSEIF ITAB-TXN_DT is initial.

message I001(zcardmesg).

stop.

ELSEIF ITAB-POSTING_DT is initial.

message I002(zcardmesg).

stop.

ELSEIF ITAB-TXN_AMT is initial.

message I003(zcardmesg).

stop.

ELSEIF ITAB-CURRENCY_KEY is initial.

message I004(zcardmesg).

stop.

ELSEIF ITAB-DEBT_CRDT is initial.

message I005(zcardmesg).

stop.

ELSEIF ITAB-UPLOAD_DT is initial.

message I006(zcardmesg).

stop.

endif.

READ TABLE ITABV WITH KEY waers = ITAB-CURRENCY_KEY.

IF SY-SUBRC EQ 0.

X = 'X'.

else.

X = 'N'.

endif.

if ITAB-DEBT_CRDT NE 'C' and ITAB-DEBT_CRDT NE 'D' .

if sy-subrc eq 0.

MOVE-CORRESPONDING ITAB TO ITABERR.

APPEND ITABERR.

CLEAR ITABERR.

else.

MOVE-CORRESPONDING ITAB TO ITABS.

APPEND ITABS.

CLEAR ITABS.

endif.

elseif X = 'X'.

MOVE-CORRESPONDING ITAB TO ITABS.

APPEND ITABS.

CLEAR ITABS.

clear X.

elseif X = 'N'.

MOVE-CORRESPONDING ITAB TO ITABERR.

APPEND ITABERR.

CLEAR ITABERR.

clear X.

endif.

ENDLOOP.

LOOP AT ITABS.

TRANSLATE ITABS-CURRENCY_KEY TO UPPER CASE.

TRANSLATE ITABS-DEBT_CRDT TO UPPER CASE.

itabS-upload_dt = sy-datum.

itabS-ernam = sy-uname.

modify itabS.

insert zpcard1 from itabS.

ENDLOOP.

ENDFORM. " DELE_REC

zpcard1 is table

all the data from flat file to itab

i have problem with validationes

like costcenter ITAB-inter_audit_cd

and ITAB-TXN_DT and ITAB-POSTING_DT

Please send the guide lines or code for above validationes

Advanced tahnsks for your reply

i look forward to your reply

Regards

Raja Sekhar.T

0 Kudos

for date validation use FM DATE_CHECK_PLAUSIBILITY

for numeric value validation try FM C14W_CHAR_NUMBER_CONVERSION (if exception is raised, the value is not numeric...

rgds,

PJ

Former Member
0 Kudos

For validating the date you can use the Function module CONVERT_DATE_TO_INTERN_FORMAT. It will return an error if the date passed in invalid. You can then move the corresponding record to the Error itab.

Sudha

Message was edited by: Sudha Mohan

0 Kudos

Plz help me

How to pass parameters in this Function module

CONVERT_DATE_TO_INTERN_FORMAT

Advanced thanks to your reply

i look forward to your reply

Regards

Raja Sekhar.T

0 Kudos

hi

data : l_date type d

try with this

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

EXPORTING

DATE_EXTERNAL = itab-date

IMPORTING

DATE_INTERNAL = l_date

EXCEPTIONS

DATE_EXTERNAL_IS_INVALID = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

***error

ENDIF.

cheers,

sasi

0 Kudos

Hi Raja,

here is program..you can use the perform Validate_data.

if you want to test the validation, just create a sample file in C: drive with name test.txt an dput the sample records in it. it checks verything you wanted and at the last prints the record of the error table.

i consider that error table (eitab). will have same formate as itab. let me know if it helps you o you want some changes.

It validates dates also.

REPORT zanid_test.

TYPES: BEGIN OF ty_itab,

costcenter(10),

post_date(10),

t_date(10),

d_c(5),

END OF ty_itab.

DATA: itab TYPE STANDARD TABLE OF ty_itab,

eitab TYPE STANDARD TABLE OF ty_itab.

DATA: wa_itab TYPE ty_itab.

DATA: BEGIN OF filetab OCCURS 0,

filedata(100),

END OF filetab.

START-OF-SELECTION.

PERFORM get_data.

PERFORM validate_data.

loop at eitab into wa_itab.

write:/ wa_itab-costcenter,wa_itab-post_date,

wa_itab-t_date,wa_itab-d_c.

endloop.

*----


FORMS -


*&----


*

*& Form GET_DATA

*&----


*

FORM get_data.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

  • CODEPAGE = ' '

filename = 'c:/test.txt'

filetype = 'ASC'

  • HEADLEN = ' '

  • LINE_EXIT = ' '

  • TRUNCLEN = ' '

  • USER_FORM = ' '

  • USER_PROG = ' '

  • DAT_D_FORMAT = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

data_tab = filetab.

  • EXCEPTIONS

    • CONVERSION_ERROR = 1

  • FILE_OPEN_ERROR = 2

  • FILE_READ_ERROR = 3

  • INVALID_TYPE = 4

  • NO_BATCH = 5

  • UNKNOWN_ERROR = 6

  • INVALID_TABLE_WIDTH = 7

  • GUI_REFUSE_FILETRANSFER = 8

  • CUSTOMER_ERROR = 9

  • OTHERS = 10

LOOP AT filetab.

SPLIT filetab-filedata

AT '|' INTO wa_itab-costcenter wa_itab-post_date

wa_itab-t_date wa_itab-d_c.

APPEND wa_itab TO itab.

CLEAR wa_itab.

ENDLOOP.

ENDFORM. " GET_DATA

&----


*& Form Validate_data

&----


FORM validate_data.

DATA: ls_date(2),

ls_month(2),

ls_year(4),

mydate LIKE SY-DATUM.

LOOP AT itab INTO wa_itab.

IF wa_itab-costcenter CN '0123456789 '.

APPEND wa_itab TO eitab.

continue.

ELSEIF wa_itab-d_c CN 'CD '.

APPEND wa_itab TO eitab.

continue.

ELSE.

SPLIT wa_itab-post_date AT '/' INTO

ls_date ls_month ls_year.

CONCATENATE ls_year ls_month ls_date INTO mydate.

CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'

EXPORTING

date = mydate

EXCEPTIONS

PLAUSIBILITY_CHECK_FAILED = 1

OTHERS = 2

.

IF sy-subrc EQ 1.

APPEND wa_itab TO eitab.

continue.

ENDIF.

clear: ls_date,ls_month,ls_year.

SPLIT wa_itab-T_date AT '/' INTO

ls_date ls_month ls_year.

CONCATENATE ls_year ls_month ls_date INTO mydate.

CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'

EXPORTING

date = mydate

EXCEPTIONS

PLAUSIBILITY_CHECK_FAILED = 1

OTHERS = 2

.

IF sy-subrc EQ 1.

APPEND wa_itab TO eitab.

ENDIF.

ENDIF.

ENDLOOP.

ENDFORM. " Validate_data

Former Member
0 Kudos

Hi Raja

Cost center|Posting Date|transaction date|D/C|

z456 | /05/2005 |5/6/2005 |'D

y789 |8/9/2005 |4/5/2005 |C

PERFORM CHECK_COST USING RC.

IF RC <> 0.

  • append record into error table

ENDIF.

PERFORM CHECK_DATE USING RC.

IF RC <> 0.

  • append record into error table

ENDIF.

FORM CHECK_COST USING RC.

RC = 4.

PERFORM CHECK_NUMEBER USING COST RC.

ENDFORM.

FORM CHECK_DATE USING RC.

DATA: BEGIN OF T_DATE OCCURS 3,

NUMBER(4) TYPE C

END OF T_DATE.

RC = 4.

SPLIT DATE AT '/' INTO TABLE T_DATE.

DESCRIBE TABLE T_DATE LINES SY-TABIX.

  • The records have to be 3: Day, Month and year

IF SY-TABIX <> 3.

EXIT.

ENDIF.

LOOP AT T_DATE.

PERFORM CHECK_NUMEBER USING T_DATE-NUMBER RC.

IF RC <> 0. EXIT. ENDIF.

ENDLOOP.

ENDFORM.

FORM CHECK_NUMEBER USING NUMBER RC.

RC = 4.

IF NUMBER CO '0123456789'.

RC = 0.

ENDIF.

ENDFORM.

Max