Skip to Content
author's profile photo Former Member
Former Member

PLz help me, Its URGENT WORK

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Oct 13, 2005 at 07:18 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 13, 2005 at 08:00 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Oct 13, 2005 at 08:10 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Before answering

    You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
    You must be Logged in to submit an answer.

    Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.