SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Create Batch and populate characteristics from Material Data



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sun Oct 14, 2007 9:08 pm    Post subject: Create Batch and populate characteristics from Material Data Reply with quote

Requirement:
In a process industry-company, a sample of material is inspected by Spectrometer ( Inspection M/C) after each batch of production. A third party software WinOE is being used to analyze and store the pig iron sample's characteristic data on an Windows NT PC ( connected to Spectrometer ). This software also generates a file for each final inspection data of a batch sample. The file name indicates the batch number ( external number range for sap ). The requirement is to determine grade, create a batch in SAP of the material being produced in the current shift / charge. Further, populate characteristics of Material / Batch using inspection data.
Here 'Grade' represents the actual material produced and it may not be the same as material desired. e.g. Process Order is raised to produce 'High Percentage Corbon Iron' and is poured accordingly but inspection results might suggest that produced material should be graded as another material.


--------------------------------------------------------------------------------
Processing:
An application written in ABAP is scheduled to run on SAP application server at regular intervals. The processing is as below:

Along with the process order, the information of current material being produced is kept in a customer table. Mainly Process Order Number, material number against date & time is maintained manually on a daily basis. Program determines the current material number and continues only if the data is maintained in this table.

Check that Remote computer is running and in the network and then transfer the inspection data file from the remote NT m/c to the SAP application server's spectrometer directory . FM 'SXPG_COMMAND_EXECUTE' can be used to run a ping command after configuring it through transaction SM69. Standard SAP's RSFTP002 is modified slightly to run FTP commands on remote PC. Remote NT M/c should be running an FTP Service and it can be achieved by running the IIS web server's FTP service as IIS comes along with Windows NT.
SUBMIT ZFTP USING SELECTION-SET 'ZSPECTRO' AND RETURN.
The variant for this program has following paramters:
User < user name of NT PC >
Password < password >
Host < IP Address of NT PC >
Command 1 cd < directory on Remote Windows NT PC >
Command 2 lcd < directory on SAP application server >
Command 3 ascii
Command 4 mget *.*
Command 5 mdelete *.*
RFC destination MYFTP < SAP application server's RFC destination in Xn SM59 >
Compress N

Get all the files from application server directory using function module EPS_GET_DIRECTORY_LISTING and process one by one.
For Each File:

Open, Read and Close current file using OPEN DATASET , READ DATASET, CLOSE DATASET
Further, parse strings and move to internal table.
Populate the customer table for inspection data with the file data fetched in last step. This table contains characteristics like Corbon%, Sulphur%, Mn% etc. against External Batch Number, Date & Time. Perfomr a check for duplicate record on this table at this point of time and data is inserted at the end of the processing.
Determine the grade of the sample pig iron by comparing the charactersics with the grade master table ( a customer table with grade determination rules ). This table contains Material with its minimum and maximum values of relevant characteristics.
Create Batch and populate characteristic values against that material and batch combination in SAP system.
Standard SAP has provided APIs for this purpose. Function Modules are 'CALO_INIT_API', 'CACL_OBJECT_ALLOCATION_MAINT', CACL_OBJECT_VALIDATION_MAINT', 'CACL_CLASSIFICATION_SAVE','VB_CREATE_BATCH' , 'CARD_CLASS_READ_CHARACTS'
Further, a customer function module 'Z_CREATE_BATCH_WITH_CHARCT' is developed using these FMs.
After finishing the processing for the current file move the file to archive directory. This is achieved by using FMs for copy 'PFL_COPY_OS_FILE' and delete 'EPS_DELETE_FILE'.
Insert records in inspection data table.

Code:
REPORT Z_INBOUND_CREATE_BATCH .
*----------------------------------------------------------------------*
*       Written By: Ram Manohar Tiwari / Rahul Aurangabadkar         
*----------------------------------------------------------------------*
*       Presented By: http://www.rmtiwari.com
*----------------------------------------------------------------------*

DATA : ERR_MSG like IWERRORMSG .
DATA : FILE_NAMES_ITAB like EPSFILI occurs 5 with header line.
DATA : BEGIN OF REC_ITAB OCCURS 17,
       FILE_LINE(100) TYPE C,
       END OF REC_ITAB.
DATA : REC_HDR(20) type C,
       REC_DTL(100) type C,
       REC_DTL_NUM LIKE ZSPECTRO_DATA-C_PERCENT.
DATA   CAST_DATE TYPE DATS.
DATA   PREV_DATE TYPE ENDDA.
DATA   TODAY TYPE BEGDA.
DATA   PERIOD TYPE  PSEN_DURATION_DEC.

DATA: BEGIN OF SPECTRO_ITAB OCCURS 0,
        MANDT TYPE ZSPECTRO_DATA-MANDT,
        CAST_NO TYPE ZSPECTRO_DATA-CAST_NO,
        SOURCE TYPE ZSPECTRO_DATA-SOURCE, "SP for normal, AL for runner
        CAST_DATE TYPE ZSPECTRO_DATA-CAST_DATE,
        CAST_TIME TYPE ZSPECTRO_DATA-CAST_TIME,
        OPERATOR TYPE ZSPECTRO_DATA-OPERATOR,    "Operator Type DB..
        MATRIX TYPE ZSPECTRO_DATA-MATRIX,      "Not Required currently
        P_PERCENT TYPE ZSPECTRO_DATA-P_PERCENT,  "Phos %
        S_PERCENT TYPE ZSPECTRO_DATA-S_PERCENT,  "Sulph %
        C_PERCENT TYPE ZSPECTRO_DATA-C_PERCENT,  "Carbon %
        SI_PERCENT TYPE ZSPECTRO_DATA-SI_PERCENT,"Silicon %
        FE_PERCENT TYPE ZSPECTRO_DATA-FE_PERCENT,"Fe      % ..Not used
        MN_PERCENT TYPE ZSPECTRO_DATA-MN_PERCENT,"Manganese %
        TI_PERCENT TYPE ZSPECTRO_DATA-TI_PERCENT,"Titanium % ..Not Used
        ZGRADE TYPE ZSPECTRO_DATA-GRADE,       "Grade - Finished Part No
        STATUS TYPE ZSPECTRO_DATA-STATUS,  "Batch Not Created in SAP "E"
        FILE_NAME TYPE ZSPECTRO_DATA-FILE_NAME, " File name
      END OF SPECTRO_ITAB.

DATA : SP_ZSPECTRO_DATA LIKE ZSPECTRO_DATA OCCURS 1 WITH HEADER LINE.

DATA : SAMPLE_REST(20) TYPE C,
       SAMPLE_NO(6) TYPE C,
       CAST_TIME(8) TYPE C.

DATA : BEGIN OF ITAB_FOR_DYN_PROGRAM OCCURS 2,
       LINE(72) TYPE C,
       END   OF ITAB_FOR_DYN_PROGRAM.
DATA  DYN_STMT(72) TYPE C.
DATA  ZEQUALS(3) TYPE C.

TABLES:  ZSPECTRO_DATA,          " Stores Data of File
         ZSPECTRO_FACTOR,        " Correction Factor
         ZCUR_PON.               " Current Process Order

DATA  TMP LIKE ZSPECTRO_DATA-CAST_NO.
DATA  DEST_FILE LIKE TPFHT-PFFILE.
DATA  FLAG(4) TYPE C.
DATA  N TYPE I.
DATA  ERROR_DESC(200) TYPE C.
DATA  VAR_GRADE LIKE ZGRADE_MASTER-ZCMIN.
PARAMETERS: FILE_DIR LIKE EPSF-EPSDIRNAM
                     DEFAULT '/home/ /interface/spectro'. "Dir Name
DATA : FILE_PATH LIKE TPFHT-PFFILE.
DATA  BATCH_MODE LIKE MCHA-CHARG.
DATA  CHAR_ITAB LIKE CHA_VALDSC OCCURS 0 WITH HEADER LINE.
DATA  VAR_MAT_DESC LIKE MAKT-MAKTX.

DATA  VAR_PON LIKE ZCUR_PON-PON.           " Process Order No
DATA  VAR_PON_TIME LIKE ZCUR_PON-PO_TIME.  " Process Order Time
DATA  OLD_PON LIKE ZCUR_PON-PON.
DATA  VAR_PON_DATE LIKE ZCUR_PON-PO_DATE.  " Process Order Date
DATA  VAR_MAT_NO LIKE MCHA-MATNR.
DATA  VAR_BATCH LIKE MCHA-CHARG.
DATA  FILES_TKN TYPE I.
DATA  VAR_CAST_NO LIKE ZSPECTRO_DATA-CAST_NO. " Cast No.

DATA : pripar TYPE pri_params,
     arcpar TYPE arc_params,
     valid  TYPE C.
DATA  TIME_LENGTH TYPE I.

* Check daily maintenance of Process Order Number.
TODAY = SY-DATUM.
PERIOD-CALDD = 2.
CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
  EXPORTING
    ID_DATE                        = TODAY
   ID_OPERATOR                    = '-'
    IS_DURATION                    = PERIOD
 IMPORTING
   ED_DATE                        = PREV_DATE
 EXCEPTIONS
   CONVERSION_NOT_SPECIFIED       = 1
   CONVERSION_NOT_POSSIBLE        = 2
   OTHERS                         = 3
          .
IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


SELECT COUNT( * )
 INTO VAR_PON
 FROM ZCUR_PON
WHERE PO_DATE >= PREV_DATE.
  IF SY-SUBRC <> 0.
     FORMAT COLOR 6 ON.
     WRITE :/ 'Please Maintain Current Process Order Number'.
     FORMAT COLOR OFF.
     EXIT.
  ENDIF.

* Setting Printer parametres for spool request
CALL FUNCTION 'GET_PRINT_PARAMETERS'
     EXPORTING
          DESTINATION            = 'LOC1'
          COPIES                 = 1           " COUNT
          LIST_NAME              = 'FTP_SPECTRO'
          LIST_TEXT              = 'SUBMIT ... TO SAP-SPOOL'
          IMMEDIATELY            = ' '
          RELEASE                = 'X'
          NEW_LIST_ID            = 'X'
          EXPIRATION             = 1           " DAYS
          LINE_SIZE              = 80
          LINE_COUNT             = 65
          LAYOUT                 = 'X_65_80'
          SAP_COVER_PAGE         = ' '
          COVER_PAGE             = ' '
          RECEIVER               = SY-UNAME
          DEPARTMENT             = 'System' 
          NO_DIALOG              = 'X'
          MODE                   = '1'
          USER                   = SY-UNAME
     IMPORTING
          out_parameters         = pripar
          out_archive_parameters = arcpar
          valid                  = valid.
IF VALID <> SPACE.
* FTP files from NT m/c to Application server's 'spectrometer'
*directory
  SUBMIT ZFTP USING SELECTION-SET 'ZSPECTRO'
         TO SAP-SPOOL WITHOUT SPOOL DYNPRO
         SPOOL PARAMETERS pripar
         ARCHIVE PARAMETERS arcpar
         AND RETURN.
ENDIF.

* SUBMIT ZFTP USING SELECTION-SET 'ZSPECTRO_VAR' AND RETURN.

* Read Directory for list of files on application server.

CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
  EXPORTING
    DIR_NAME                     = FILE_DIR
    FILE_MASK                    = '*.*'
* IMPORTING                         
*   DIR_NAME                     =   
*   FILE_COUNTER                 =   
*   ERROR_COUNTER                =   
  TABLES
    DIR_LIST                     = FILE_NAMES_ITAB
 EXCEPTIONS
   INVALID_EPS_SUBDIR           = 1
   SAPGPARAM_FAILED             = 2
   BUILD_DIRECTORY_FAILED       = 3
   NO_AUTHORIZATION             = 4
   READ_DIRECTORY_FAILED        = 5
   TOO_MANY_READ_ERRORS         = 6
   EMPTY_DIRECTORY_LIST         = 7
   OTHERS                       = 8
          .
IF SY-SUBRC <> 0.
   FORMAT COLOR 6 ON.
   WRITE : / 'Problem in directory reading'.
   FORMAT COLOR OFF.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO 
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 
ENDIF.

CLEAR FILE_NAMES_ITAB.
* WRITE : / FILE_NAMES_ITAB. 
DESCRIBE TABLE FILE_NAMES_ITAB LINES FILES_TKN.
IF FILES_TKN < 1.
  WRITE : / 'NO FILES AVAILABLE FOR UPLOADING', FILES_TKN .
  EXIT.
ENDIF.

* Processing all files in the named directory 

LOOP AT FILE_NAMES_ITAB.
  CONCATENATE FILE_DIR '/' FILE_NAMES_ITAB-NAME INTO FILE_PATH.
  WRITE : /.
  FORMAT COLOR 1 ON.
  WRITE :/ 'Processing File : ',FILE_PATH.
  FORMAT COLOR OFF.
  CLEAR REC_ITAB. REFRESH REC_ITAB.

* Uploading each file from presentation server 

* PERFORM CHECK_FILE_FORMAT.   

  OPEN DATASET FILE_PATH FOR INPUT IN TEXT MODE.

  IF SY-SUBRC <> 0.
    WRITE : / 'PROBLEM IN READING FILE IN REC_ITAB'.
    FLAG = 'ERR'.
    PERFORM MOVE_FILE USING FLAG.
    CLEAR FLAG.
    CONTINUE.
  ELSE.
    DO.
      READ DATASET FILE_PATH INTO REC_ITAB.
      IF SY-SUBRC = 0 .
        APPEND REC_ITAB.
      ELSE.
        EXIT.
      ENDIF.
    ENDDO.
    CLOSE DATASET FILE_PATH.
*     IF FLAG = 'ERR' . 
*        WRITE : / 'Error in File ',FILE_PATH.
*        PERFORM MOVE_FILE USING FLAG.         
*        CLEAR FLAG.                           
*        CONTINUE.                             
*     ENDIF.                                   




*   Parsing string and putting in the fields of the internal table
*   SPECTRO_ITAB 

    PERFORM UPLOAD_TO_TABLE.

    CLEAR SP_ZSPECTRO_DATA. REFRESH SP_ZSPECTRO_DATA.

* Check for duplicate record   

    SELECT SINGLE *  INTO SP_ZSPECTRO_DATA FROM ZSPECTRO_DATA
     WHERE CAST_NO = SPECTRO_ITAB-CAST_NO
       AND CAST_DATE = SPECTRO_ITAB-CAST_DATE
       AND CAST_TIME = SPECTRO_ITAB-CAST_TIME
       AND SOURCE = SPECTRO_ITAB-SOURCE.          " SP or AL

    IF SY-SUBRC = 0.
       FORMAT COLOR 6 ON.
       WRITE : / 'DUPLICATE RECORD FOR FILE ' ,
                 SP_ZSPECTRO_DATA-FILE_NAME.  "FILE_NAMES_ITAB-NAME.
       FORMAT COLOR OFF.
       FLAG = 'ERR'.
       PERFORM MOVE_FILE USING FLAG.
       CLEAR : REC_ITAB, SP_ZSPECTRO_DATA,SPECTRO_ITAB,CHAR_ITAB.
       REFRESH : REC_ITAB,SP_ZSPECTRO_DATA,SPECTRO_ITAB,CHAR_ITAB.
       CLEAR FLAG.
       CONTINUE.
    ELSE.

*   Get the grade ( Finished good part No)             
*   based on the % values of metals and update         
*   characteristics value for Grade in CHAR_ITAB internal tab

      PERFORM GET_GRADE.
      CLEAR SP_ZSPECTRO_DATA. REFRESH SP_ZSPECTRO_DATA.

*Check cast no and source for batch creation       

      SELECT * INTO TABLE SP_ZSPECTRO_DATA FROM ZSPECTRO_DATA
       WHERE CAST_NO = SPECTRO_ITAB-CAST_NO
*         AND CAST_DATE = SPECTRO_ITAB-CAST_DATE   
         AND SOURCE    = 'SP'.

      IF SY-DBCNT > 1.  "More than one SP record for the CAST NO
        FORMAT COLOR 6 ON.
        WRITE: / 'More than one SP record for the CAST Invalid File '
                 , FILE_NAMES_ITAB-NAME.
        FORMAT COLOR OFF.
        FLAG = 'ERR'.
        PERFORM MOVE_FILE USING FLAG.
        CLEAR : REC_ITAB, SP_ZSPECTRO_DATA,SPECTRO_ITAB,CHAR_ITAB.
        REFRESH : REC_ITAB,SP_ZSPECTRO_DATA,SPECTRO_ITAB,CHAR_ITAB.
        CLEAR FLAG.
        CONTINUE.
      ELSEIF SY-DBCNT = 1.  "Cast No with source SP exists
        FORMAT COLOR 2 ON.
        WRITE : / 'CAST NO ',SPECTRO_ITAB-CAST_NO,
                  ' WITH SOURCE SP EXISTS'.
        FORMAT COLOR OFF.

*       If source is not AL for current cast continue with new file by
*       Raise error
        IF SPECTRO_ITAB-SOURCE = 'AL'. "source is AL for current cast no
          read table sp_zspectro_data index 1.
*   Compare Grade of current cast(source AL) and that of cast with
*   source SP. If same, update the batch with current % values of metals
*   else create a new cast number by concatenating 'A' to the cast
*   number.
          IF SPECTRO_ITAB-ZGRADE = sp_zspectro_data-grade.
            FORMAT COLOR 1 ON.
            WRITE : / 'SP GRADE IS EQUAL TO AL GRADE, BATCH IS UPDATED'.
            FORMAT COLOR OFF.
            BATCH_MODE = 'UPDATE'.
          ELSE.
            FORMAT COLOR 1 ON.
            WRITE : / 'SP GRADE IS NOT EQUAL TO AL GRADE'.
            FORMAT COLOR OFF.
            CONCATENATE SPECTRO_ITAB-CAST_NO 'A' INTO
                        SPECTRO_ITAB-CAST_NO.
*           Check if the new cast number already exists in the
*           ZSPECTRO_DATA table.
            SELECT CAST_NO INTO VAR_CAST_NO FROM ZSPECTRO_DATA
             WHERE CAST_NO = SPECTRO_ITAB-CAST_NO.
            ENDSELECT.
            CLEAR VAR_CAST_NO.

*           If found update the batch with new charactreistic values
*           else create a new batch with concatenated cast number   

            IF SY-DBCNT GE 1.
              FORMAT COLOR 2 ON.
              WRITE : / SPECTRO_ITAB-CAST_NO,
               ' BATCH ALREADY EXITS FOR AL GRADE, UPDATING THE BATCH'.
              FORMAT COLOR OFF.
              BATCH_MODE = 'UPDATE'.
            ELSE.
              BATCH_MODE = 'CREATE'.
*              WRITE : / SPECTRO_ITAB-CAST_NO, ' BATCH CREATED'. 
            ENDIF.
          ENDIF.
        ELSE.
          FORMAT COLOR 6 ON.
          WRITE : / 'Invalid SOURCE for file. Should be AL only'.
          FORMAT COLOR 6 ON.
          FLAG = 'ERR'.
          PERFORM MOVE_FILE USING FLAG.
          CLEAR : REC_ITAB, SP_ZSPECTRO_DATA,SPECTRO_ITAB,CHAR_ITAB..
          REFRESH : REC_ITAB,SP_ZSPECTRO_DATA,SPECTRO_ITAB,CHAR_ITAB..
          CLEAR FLAG.
          CONTINUE.
        ENDIF.
      ELSE.

          BATCH_MODE = 'CREATE'.
*        ENDIF.
      ENDIF.

* Inserting details for cast into ZSPECTRO_DATA SAP table. If inserted
* move file to DONE directory else move file to ERR directory

      INSERT ZSPECTRO_DATA  FROM SPECTRO_ITAB .

      IF SY-SUBRC = 0. "Check for successful insertion
        COMMIT WORK.
        FORMAT COLOR 2 ON.
        WRITE :/ 'RECORD INSERTED IN TABLE'.
        FORMAT COLOR OFF.
        FLAG = 'DONE'.
*        PERFORM MOVE_FILE USING FLAG.

*  Create or update the batch depending on 'BATCH_MODE'. Also get the
*  current process order number

        PERFORM CREATE_OR_UPDATE_BATCH.

      ELSE.
        FORMAT COLOR 6 ON.
        WRITE : / 'Problem while insertion in ZSPECTRO_DATA'.
        FORMAT COLOR OFF.
        FLAG = 'ERR'.
      ENDIF.

    ENDIF.
  ENDIF.
  PERFORM MOVE_FILE USING FLAG.
  CLEAR : REC_ITAB, SP_ZSPECTRO_DATA,SPECTRO_ITAB,CHAR_ITAB,
          VAR_MAT_NO,VAR_PON,VAR_PON_TIME,VAR_PON_DATE,VAR_BATCH.
  REFRESH : REC_ITAB,SP_ZSPECTRO_DATA,SPECTRO_ITAB,CHAR_ITAB.
  CLEAR FLAG.
ENDLOOP.
*&---------------------------------------------------------------------*
*&      Form  UPLOAD_TO_TABLE                  
*&---------------------------------------------------------------------*
*       text                           
*----------------------------------------------------------------------*
*  -->  p1        text                                                   
*  <--  p2        text                                                   
*----------------------------------------------------------------------*
FORM UPLOAD_TO_TABLE.
  CLEAR SPECTRO_ITAB. REFRESH SPECTRO_ITAB.
  LOOP AT REC_ITAB.

    SPLIT REC_ITAB-FILE_LINE AT ':' INTO REC_HDR REC_DTL.
    SHIFT REC_DTL LEFT  DELETING LEADING  SPACE.
    IF  ( REC_HDR NE 'Program' ) AND
        ( REC_HDR NE 'Task' ) AND
        ( REC_HDR NE 'Quality' ) AND
        ( REC_HDR NE 'Type Standard' ) AND
        ( REC_HDR NE 'Run Number' ) AND
        ( REC_HDR NE 'Elements' ) AND
        ( REC_HDR NE 'Record' )
        .
      IF REC_HDR EQ 'Date'.
        PERFORM GET_DATE_IN_ITAB.

      ELSEIF REC_HDR EQ 'Sample'.
        PERFORM GET_SAMPLE_IN_ITAB.
      ELSE.

  CLEAR ZSPECTRO_FACTOR.

  SELECT * UP TO 1 ROWS FROM ZSPECTRO_FACTOR
  ORDER BY ENTRY_DT DESCENDING ENTRY_TIME DESCENDING.
  ENDSELECT.

  IF SY-SUBRC <> 0 OR ZSPECTRO_FACTOR-C_FACTOR IS INITIAL
                   OR ZSPECTRO_FACTOR-SI_FACTOR IS INITIAL
                   OR ZSPECTRO_FACTOR-MN_FACTOR IS INITIAL
                   OR ZSPECTRO_FACTOR-S_FACTOR IS INITIAL
                   OR ZSPECTRO_FACTOR-P_FACTOR IS INITIAL.
     WRITE : / 'Please maintain correction factor'.
     WRITE : / 'Exiting .................'.
     EXIT.
  ENDIF.

        CASE REC_HDR.
*         % is to be multipied with Correction factor     
          WHEN 'Matrix'.
            SPECTRO_ITAB-MATRIX = REC_DTL.
          WHEN 'P'.
            CHAR_ITAB-CHARACT = 'PHOSPHORUS'.
            REC_DTL_NUM = ( REC_DTL * ZSPECTRO_FACTOR-P_FACTOR ).
            SPECTRO_ITAB-P_PERCENT = REC_DTL_NUM.
          WHEN 'S'.
            CHAR_ITAB-CHARACT = 'SULPHUR'.
            REC_DTL_NUM = ( REC_DTL * ZSPECTRO_FACTOR-S_FACTOR ).
            SPECTRO_ITAB-S_PERCENT = REC_DTL_NUM.
          WHEN 'C'.
            CHAR_ITAB-CHARACT = 'CARBON'.
            REC_DTL_NUM = ( REC_DTL * ZSPECTRO_FACTOR-C_FACTOR ).
            SPECTRO_ITAB-C_PERCENT = REC_DTL_NUM.
          WHEN 'Fe'.
            CHAR_ITAB-CHARACT = 'IRON'.
*            REC_DTL = ( REC_DTL * ZSPECTRO_FACTOR-FE_FACTOR ).
            SPECTRO_ITAB-Fe_PERCENT = REC_DTL.
          WHEN 'Si'.
            CHAR_ITAB-CHARACT = 'SILICON'.
            REC_DTL_NUM = ( REC_DTL * ZSPECTRO_FACTOR-SI_FACTOR ).
            SPECTRO_ITAB-Si_PERCENT = REC_DTL_NUM.
          WHEN 'Mn'.
            CHAR_ITAB-CHARACT = 'MANGANESE'.
            REC_DTL_NUM = ( REC_DTL * ZSPECTRO_FACTOR-MN_FACTOR ).
            SPECTRO_ITAB-Mn_PERCENT = REC_DTL_NUM.
*          WHEN 'Ti'.                           
*            CHAR_ITAB-CHARACT = 'TITANIUM'.     
*            SPECTRO_ITAB-Ti_PERCENT = REC_DTL. 
        ENDCASE.
        IF REC_HDR = 'P'  OR REC_HDR = 'S' OR
           REC_HDR = 'C'  OR REC_HDR = 'Fe' OR
           REC_HDR = 'Si' OR REC_HDR = 'Mn'.
          CHAR_ITAB-VALUE = REC_DTL_NUM.
          APPEND CHAR_ITAB.
        ENDIF.
        CLEAR : REC_HDR,REC_DTL,REC_DTL_NUM,CHAR_ITAB.
      ENDIF.
    ENDIF.
  ENDLOOP.
  SPECTRO_ITAB-FILE_NAME = FILE_NAMES_ITAB-NAME.
  SPECTRO_ITAB-STATUS = ' '.
  APPEND SPECTRO_ITAB.

ENDFORM.                    " UPLOAD_TO_TABLE

*&---------------------------------------------------------------------*
*&      Form  GET_CONVERTED_DATE                  
*&---------------------------------------------------------------------*
*       text                           
*----------------------------------------------------------------------*
*  -->  p1        text                     
*  <--  p2        text                     
*----------------------------------------------------------------------*
FORM GET_DATE_IN_ITAB.
  SHIFT REC_DTL LEFT BY 6 PLACES.
  DO 2 TIMES.
    REPLACE ',' WITH SPACE  INTO REC_DTL.
  ENDDO.
  CONDENSE REC_DTL NO-GAPS.
  CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
       EXPORTING
            DATE_EXTERNAL            = REC_DTL
       IMPORTING
            DATE_INTERNAL            = SPECTRO_ITAB-CAST_DATE
       EXCEPTIONS
            DATE_EXTERNAL_IS_INVALID = 1
            OTHERS                   = 2.
  IF SY-SUBRC <> 0.
     FORMAT COLOR 6 ON.
     WRITE : / 'Problem in date conversion'.
     FORMAT COLOR OFF.

*    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO 
*           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.   
  ENDIF.



ENDFORM.                    " GET_CONVERTED_DATE

*&---------------------------------------------------------------------*
*&      Form  GET_SAMPLE_IN_ITAB                  
*&---------------------------------------------------------------------*
*       text                           
*----------------------------------------------------------------------*
*  -->  p1        text                     
*  <--  p2        text                     
*----------------------------------------------------------------------*
FORM GET_SAMPLE_IN_ITAB.

  SPLIT REC_DTL AT ',' INTO SPECTRO_ITAB-CAST_NO
                            CAST_TIME
                            SPECTRO_ITAB-SOURCE
                            SPECTRO_ITAB-OPERATOR
                            SAMPLE_REST.


  REPLACE '.' WITH SPACE INTO CAST_TIME.
  REPLACE ':' WITH SPACE INTO CAST_TIME.
  CONDENSE CAST_TIME NO-GAPS.
  CONCATENATE CAST_TIME '00' INTO CAST_TIME.
  TIME_LENGTH = STRLEN( CAST_TIME ).
  IF TIME_LENGTH = 5 .
     CONCATENATE '0' CAST_TIME INTO CAST_TIME.
  ENDIF.

  CALL FUNCTION 'CONVERT_TIME_INPUT'
       EXPORTING
            INPUT                     = CAST_TIME
            PLAUSIBILITY_CHECK        = 'X'
       IMPORTING
            OUTPUT                    = SPECTRO_ITAB-CAST_TIME
       EXCEPTIONS
            PLAUSIBILITY_CHECK_FAILED = 1
            WRONG_FORMAT_IN_INPUT     = 2
            OTHERS                    = 3.
  IF SY-SUBRC <> 0.
     FORMAT COLOR 6 ON.
     WRITE : / 'Problem in TIME conversion'.
     WRITE : SY-MSGV1, SY-MSGV2, SY-MSGV3, SY-MSGV4.
     FORMAT COLOR OFF.
     SPECTRO_ITAB-CAST_TIME = '00:00:00'.
*    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO   
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.   
  ENDIF.

ENDFORM.                    " GET_SAMPLE_IN_ITAB

*&---------------------------------------------------------------------*
*&      Form  MOVE_FILE_TO_DONE                  
*&---------------------------------------------------------------------*
*       text                           
*----------------------------------------------------------------------*
*  -->  p1        text                     
*  <--  p2        text                             
*----------------------------------------------------------------------*
FORM MOVE_FILE USING FLAG.

  IF FLAG = 'DONE'.
    CONCATENATE FILE_DIR '/done/' SPECTRO_ITAB-CAST_NO '_'
                                  SPECTRO_ITAB-SOURCE  '_'
                                  FILE_NAMES_ITAB-NAME INTO DEST_FILE.
    CLEAR FLAG.
  ELSE.
    CONCATENATE FILE_DIR '/err/' SPECTRO_ITAB-CAST_NO '_'
                                 SPECTRO_ITAB-SOURCE  '_'
                                 FILE_NAMES_ITAB-NAME INTO DEST_FILE.
    CLEAR FLAG.
  ENDIF.
  CALL FUNCTION 'PFL_COPY_OS_FILE'
       EXPORTING
            SOURCE_FILE_NAME        = FILE_PATH
            TARGET_FILE_NAME        = DEST_FILE
       EXCEPTIONS
            CANT_OPEN_SOURCEFILE    = 1
            CANT_OPEN_TARGETFILE    = 2
            ERROR_WRITING_TAGETFILE = 3
            OTHERS                  = 4.
  IF SY-SUBRC <> 0.
    WRITE : / 'Problem while copying file from ',FILE_PATH,
             ' to ', DEST_FILE.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO 
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 
  ENDIF.

  CALL FUNCTION 'EPS_DELETE_FILE'
    EXPORTING
      FILE_NAME                    = FILE_NAMES_ITAB-NAME
      DIR_NAME                     = FILE_DIR
* IMPORTING            
*   FILE_PATH                    =   
   EXCEPTIONS
     INVALID_EPS_SUBDIR           = 1
     SAPGPARAM_FAILED             = 2
     BUILD_DIRECTORY_FAILED       = 3
     NO_AUTHORIZATION             = 4
     BUILD_PATH_FAILED            = 5
     DELETE_FAILED                = 6
     OTHERS                       = 7
            .
  IF SY-SUBRC <> 0.
    WRITE : / 'Problem while deleting file ',FILE_PATH.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.





ENDFORM.                    " MOVE_FILE
*&---------------------------------------------------------------------*
*&      Form  CHECK_FILE_FORMAT                  
*&---------------------------------------------------------------------*
*       text                           
*----------------------------------------------------------------------*
*  -->  p1        text                     
*  <--  p2        text                     
*----------------------------------------------------------------------*
FORM CHECK_FILE_FORMAT.

  DESCRIBE TABLE REC_ITAB LINES N.
  IF N <> 17.
    WRITE : / 'INVALID FILE FORMAT. THE FILE SHOULD CONTAIN 17 LINES.' .
 
  ENDIF.
  LOOP AT REC_ITAB.
  ENDLOOP.
ENDFORM.                    " CHECK_FILE_FORMAT

*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*       text                           
*----------------------------------------------------------------------*
*  -->  p1        text                     
*  <--  p2        text                     
*----------------------------------------------------------------------*
FORM GET_GRADE.
  READ TABLE SPECTRO_ITAB INDEX 1.

 SELECT ZGRADE INTO SPECTRO_ITAB-ZGRADE FROM ZGRADE_MASTER
  WHERE ZCMIN <=  SPECTRO_ITAB-C_PERCENT
    AND ZCMAX >=  SPECTRO_ITAB-C_PERCENT
    AND ZSIMIN <= SPECTRO_ITAB-SI_PERCENT
    AND ZSIMAX >= SPECTRO_ITAB-SI_PERCENT
    AND ZMNMIN <= SPECTRO_ITAB-MN_PERCENT
    AND ZMNMAX >= SPECTRO_ITAB-MN_PERCENT
    AND ZSMIN <=  SPECTRO_ITAB-S_PERCENT
    AND ZSMAX >=  SPECTRO_ITAB-S_PERCENT
    AND ZPMIN <=  SPECTRO_ITAB-P_PERCENT
    AND ZPMAX >=  SPECTRO_ITAB-P_PERCENT.
 ENDSELECT.
  IF SY-SUBRC NE 0.
    SPECTRO_ITAB-ZGRADE = 'PI400'.         "Other Grade 'OG'
  ENDIF.
  CHAR_ITAB-CHARACT = 'GRADE'.
  CHAR_ITAB-VALUE = SPECTRO_ITAB-ZGRADE.
  APPEND CHAR_ITAB.
*  WRITE : / 'GRADE IS ' , SPECTRO_ITAB-ZGRADE. 

ENDFORM.                    " GET_GRADE
*&---------------------------------------------------------------------*
*&      Form  CREATE_OR_UPDATE_BATCH                  
*&---------------------------------------------------------------------*
*       text                           
*----------------------------------------------------------------------*
*  -->  p1        text                     
*  <--  p2        text                     
*----------------------------------------------------------------------*
FORM CREATE_OR_UPDATE_BATCH.

* Get Material number for current process order number

  PERFORM GET_PON.

  VAR_BATCH = SPECTRO_ITAB-CAST_NO.
  CALL FUNCTION 'ZCREATE_BATCH_FOR_PROD_MATL'
       EXPORTING
            CLASS           = 'CAST'
            CLASSTYP        = '022'
            BATCH           = VAR_BATCH  "batch no to be created
            MATERIAL        = VAR_MAT_NO  "material no for the batch
            PLANT           = '1000'
            BATCH_MODE      = BATCH_MODE  "create or update
       TABLES
            CHAR_VALUE_ITAB = CHAR_ITAB. "% values and grade for batch

* If batch is not created, set status = 'E' for that record in
* SAP table ZSPECTRO_DATA and move file to done. 
  IF SY-SUBRC = 0.
*    WRITE :/ 'Batch ',VAR_BATCH, ' Created successfully'.
     COMMIT WORK.
  ELSE.
    FORMAT COLOR 6 ON.
    WRITE :/ 'Problem in batch creation'.
    FORMAT COLOR OFF.
    UPDATE ZSPECTRO_DATA
       SET STATUS = 'E'
     WHERE CAST_NO = SPECTRO_ITAB-CAST_NO
       AND SOURCE = SPECTRO_ITAB-SOURCE
       AND CAST_DATE = SPECTRO_ITAB-CAST_DATE
       AND CAST_TIME = SPECTRO_ITAB-CAST_TIME.
    COMMIT WORK.
  ENDIF.
  FLAG = 'DONE'.
ENDFORM.                    " CREATE_OR_UPDATE_BATCH
*&---------------------------------------------------------------------*
*&      Form  GET_PON                     
*&---------------------------------------------------------------------*
*       text                           
*----------------------------------------------------------------------*
*  -->  p1        text                     
*  <--  p2        text                     
*----------------------------------------------------------------------*
FORM GET_PON.

* Select valid material number depending on cast date and time
 CLEAR VAR_PON.
 SELECT PON PO_DATE PO_TIME
   INTO (VAR_PON,VAR_PON_DATE,VAR_PON_TIME)
   FROM ZCUR_PON UP TO 1 ROWS
  WHERE PO_DATE <= SPECTRO_ITAB-CAST_DATE
  ORDER BY PO_DATE DESCENDING PO_TIME DESCENDING.
  SELECT SINGLE PLNBEZ GSTRS
    INTO (VAR_MAT_NO,VAR_PON_DATE)
    FROM AFKO
   WHERE AUFNR = VAR_PON.

*  SELECT MATL_NO PON PO_TIME PO_DATE                   
*  INTO (VAR_MAT_NO,VAR_PON,VAR_PON_TIME,VAR_PON_DATE)   
*    FROM ZCUR_PON UP TO 1 ROWS                         
*   WHERE PO_DATE <= SPECTRO_ITAB-CAST_DATE             
*   ORDER BY PO_DATE DESCENDING PO_TIME DESCENDING.     
*    IF ( ( VAR_PON_TIME <= SPECTRO_ITAB-CAST_TIME       
*           AND VAR_PON_DATE = SPECTRO_ITAB-CAST_DATE ) 
*           OR VAR_PON_DATE < SPECTRO_ITAB-CAST_DATE ). 
*    CLEAR OLD_PON.                                     
    IF ( VAR_PON_DATE > SPECTRO_ITAB-CAST_DATE ).
      WRITE : 'PON not maintained properly'.
      EXIT.
    ENDIF.
  ENDSELECT.

ENDFORM.                    " GET_PON


Code:

*----------------------------------------------------------------------*
*       Written By: Ram Manohar Tiwari                
*----------------------------------------------------------------------*
*       Presented By: http://www.rmtiwari.com
*----------------------------------------------------------------------*
FUNCTION Z_CREATE_BATCH_WITH_CHARCT .
*"----------------------------------------------------------------------*"
*"Local interface:
*"  IMPORTING
*"     REFERENCE(CLASS) TYPE  KLAH-CLASS
*"     REFERENCE(CLASSTYP) TYPE  KSSK-KLART
*"     REFERENCE(BATCH) TYPE  MCHA-CHARG
*"     REFERENCE(MATERIAL) TYPE  MCHA-MATNR
*"     REFERENCE(PLANT) TYPE  MCHA-WERKS
*"     REFERENCE(BATCH_MODE) TYPE  MCHA-CHARG
*"  TABLES
"      CHAR_VALUE_ITAB STRUCTURE  CHA_VALDSC
*"----------------------------------------------------------------------
*parameter : material like mcha-matnr obligatory,
*            batch like mcha-charg obligatory,
*            plant like mcha-werks obligatory,
*            class like klah-class obligatory,
*            classtyp like kssk-klart obligatory.
*
*********************************************************************
*-------------------------------------------------------------------*
* Initialize logfile
*-------------------------------------------------------------------*
  perform api_init_logfile.


*-------------------------------------------------------------------*
* Allocate object: material
*-------------------------------------------------------------------*
  IF BATCH_MODE = 'CREATE' .
  perform create_batch using material    "material
                             plant       "plant
                             batch.      "batch
  ENDIF.

*-------------------------------------------------------------------*
* Allocate object: material
*-------------------------------------------------------------------*
  perform cf_alloc_obj using  material           " 
                              batch              " batch
                              class              "
                              classtyp.          " .

*-------------------------------------------------------------------*
* Classes: read assigned characteristics
*-------------------------------------------------------------------*
  perform cl_read_ct tables cl_char_list
                            cl_char_val
                     using  class
                            classtyp.      "

 clear : cf_value,cf_value[],cl_char_val,cl_char_val[].


 loop at cl_char_list.
    read table char_value_itab
         with key charact = cl_char_list-charact.
    if sy-subrc = 0.
       cl_char_val-charact = char_value_itab-charact.
       cl_char_val-value = char_value_itab-value.      "Populate characterstic values from
                                              "internal table
       append cl_char_val.
    endif.
 endloop.
*-------------------------------------------------------------------*
* Object validation
*-------------------------------------------------------------------*

* Add validation 
  perform cf_valid tables cf_value
                   using  cl_char_val-charact     
                          cl_char_val-value.     

  endloop.
* Execute ...
  perform cf_exec_valid tables cf_value
                        using  material          "''
                               batch
                               class             "''
                               classtyp.           "''.




ENDFUNCTION.
*********************************************************************
* F O R M  -  Routines
*********************************************************************

*-------------------------------------------------------------------*
* Initialize logfile
*-------------------------------------------------------------------*

form api_init_logfile.
  call function 'CALO_INIT_API'
     exceptions
        log_object_not_found     = 1
        log_sub_object_not_found = 2
        others                   = 3.
  if sy-subrc <> 0.
    "error handling ...
  endif.
endform.

*-------------------------------------------------------------------*
* Allocate object: material
*-------------------------------------------------------------------*
form cf_alloc_obj using material     type c "cf_object    type c
                        batch        type c
                        cf_class     type c
                        cf_classtype type c.

  data:
     cf_obj_id      like api_ob_key occurs 0 with header line.

  data:  class      like klah-class,
         classtype  like kssk-klart.

  class     = cf_class.
  classtype = cf_classtype.

  cf_obj_id-field = 'MATNR'.
  cf_obj_id-value = material.
  append cf_obj_id.
  cf_obj_id-field = 'WERKS'.
  cf_obj_id-value = '1000'.
  append cf_obj_id.
  cf_obj_id-field = 'CHARG'.
  cf_obj_id-value = batch.
  append cf_obj_id.


  call function 'CACL_OBJECT_ALLOCATION_MAINT'
       exporting
            object_type           = 'MCHA'
            class                 = class
            class_type            = classtype
       tables
            object_identification = cf_obj_id
       exceptions
            error                 = 1
            warning               = 2
            others                = 3.

  if sy-subrc <> 0.
    "error handling...
    FORMAT COLOR 6 ON.
    write : 'Problem while maintaining classification'.
    write : 'for class ',class,' type ',classtype.
    write :/ ' Object_id ', cf_obj_id .
    FORMAT COLOR OFF.
  else.
    call function 'CACL_CLASSIFICATION_SAVE'
         exporting
             I_commit            = 'X'
             I_WAIT              = 'X'
         exceptions
              others              = 1.
*    commit work and wait.
  endif.

endform.

*-------------------------------------------------------------------*
* Object validation
*-------------------------------------------------------------------*
form cf_valid tables cf_value      structure api_ausp
              using  cf_char       type c
                     cf_char_value type c.

  cf_value-charact  = cf_char.
  cf_value-value    = cf_char_value.
  cf_value-fldelete = ' '.
  append cf_value.

endform.

*-------------------------------------------------------------------*
* Object validation: execute
*-------------------------------------------------------------------*
form cf_exec_valid tables cf_value    structure api_ausp
                   using material     type c "cf_object    type c
                         batch        type c
                         cf_class     type c
                         cf_classtype type c.

  data:
     cf_obj_id      like api_ob_key occurs 0 with header line.

  data:  class      like klah-class,
         classtype  like kssk-klart.

  class     = cf_class.
  classtype = cf_classtype.

  cf_obj_id-field = 'MATNR'.
  cf_obj_id-value = material.
  append cf_obj_id.
  cf_obj_id-field = 'WERKS'.
  cf_obj_id-value = '1000'.
  append cf_obj_id.
  cf_obj_id-field = 'CHARG'.
  cf_obj_id-value = batch.
  append cf_obj_id.

  commit work and wait.
  wait up to 2 seconds.
  call function 'CACL_OBJECT_VALIDATION_MAINT'
       exporting
            object_type           = 'MCHA'
            class                 = class
            class_type            = classtype
       tables
            object_identification = cf_obj_id
            validation_maint      = cf_value
       exceptions
            error                 = 1
            others                = 2.

  if sy-subrc <> 0.
    "error handling...
    FORMAT COLOR 6 ON.
    write : 'Problem while maintaining validation'.
    write : / cf_obj_id.
    write : / cf_value.
    FORMAT COLOR OFF.
  else.
    call function 'CACL_CLASSIFICATION_SAVE'
         exporting
             I_commit            = 'X'
             I_WAIT              = 'X'
         exceptions
              others              = 1.

    FORMAT COLOR 2 ON.
    write : /'Characterstic values populated for batch ',batch.
    FORMAT COLOR OFF.
  endif.

endform.

*-------------------------------------------------------------------*
* Allocate object: Batch
*-------------------------------------------------------------------*
form create_batch using material     type c "cf_object    type c
                        plant        type c
                        batch        type c.

  data : itab_mcha like mcha occurs 0 with header line.

  itab_mcha-matnr = material.
  itab_mcha-werks = plant.
  itab_mcha-charg = batch.
  append itab_mcha.

CALL FUNCTION 'VB_CREATE_BATCH'
  EXPORTING
    YMCHA                              = itab_mcha
*   NEW_LGORT                           = '1010'
*   BYPASS_LOCK                        = ' '
*    MESSAGE_WHEN_AUTO                  = 'X'
*   X_BNCOM                            =
*   QM_ZUSTD                           =
*   REF_MATNR                          =
*   REF_CHARG                          =
*   REF_WERKS                          =
*    KZCLA                              = 'X'
*    XKCFC                              = 'X'
*    CLASS                              = 'CAST'
*   NO_CHECK_OF_QM_CHAR                = ' '
*   BUFFER_REFRESH                     = ' '
*   NO_CHANGE_DOCUMENT                 = ' '
*   CHECK_EXTERNAL                     = X
*   CHECK_CUSTOMER                     = X
*   NO_CFC_CALLS                       = ' '
* IMPORTING
*   YMCHA                              =
* TABLES
*   CHAR_OF_BATCH                      = itab_char
*   NEW_BATCH                          = itab_NEW_BATCH
*   NEW_BATCH_STOLOC                   = itab_NEW_BATCH_STOLOC
 EXCEPTIONS
   NO_MATERIAL                        = 1
   NO_BATCH                           = 2
   NO_PLANT                           = 3
   MATERIAL_NOT_FOUND                 = 4
   PLANT_NOT_FOUND                    = 5
   STOLOC_NOT_FOUND                   = 6
   LOCK_ON_MATERIAL                   = 7
   LOCK_ON_PLANT                      = 8
   LOCK_ON_BATCH                      = 9
   LOCK_SYSTEM_ERROR                  = 10
   NO_AUTHORITY                       = 11
   BATCH_EXIST                        = 12
   STOLOC_EXIST                       = 13
   ILLEGAL_BATCH_NUMBER               = 14
   NO_BATCH_HANDLING                  = 15
   NO_VALUATION_AREA                  = 16
   VALUATION_TYPE_NOT_FOUND           = 17
   NO_VALUATION_FOUND                 = 18
   ERROR_AUTOMATIC_BATCH_NUMBER       = 19
   CANCELLED                          = 20
   WRONG_STATUS                       = 21
   INTERVAL_NOT_FOUND                 = 22
   NUMBER_RANGE_NOT_EXTERN            = 23
   OBJECT_NOT_FOUND                   = 24
   ERROR_CHECK_BATCH_NUMBER           = 25
   NO_EXTERNAL_NUMBER                 = 26
   NO_CUSTOMER_NUMBER                 = 27
   NO_CLASS                           = 28
   ERROR_IN_CLASSIFICATION            = 29
   INCONSISTENCY_IN_KEY               = 30
   OTHERS                             = 31
          .



  if sy-subrc <> 0.
    "error handling...
    FORMAT COLOR 6 ON.
    WRITE: / 'Problem in VB_CREATE_BATCH'.
    FORMAT COLOR OFF.
*    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  else.
     FORMAT COLOR 2 ON.
     write : 'Batch ' ,batch ,'Created for material', material.
     FORMAT COLOR OFF.
     commit work and wait.
     wait up to 2 seconds.
  endif.

endform.

*-------------------------------------------------------------------*
* Classes: read assigned characteristics
*-------------------------------------------------------------------*
form cl_read_ct tables cl_char_list structure cla_ch_at
                       cl_char_val  structure cha_valdsc
                using  cl_name      like clclasses-class
                       cl_type      like clclasses-class_type.

  data:  basic_data      like clbasd,
         catchword       like cla_descr-catchword,
         class_not_valid like rmclm-basisd,
         document_ident  like doc_ident.

  call function 'CARD_CLASS_READ_CHARACTS'
       exporting
            class                  = cl_name
            class_type             = cl_type
            fl_with_char_values    = 'X'
       importing
            basic_data             = basic_data
            description            = catchword
            class_not_valid        = class_not_valid
            document_ident         = document_ident
       tables
            characteristics        = cl_char_list
            characteristics_values = cl_char_val
       exceptions
            others                 = 1.

  if sy-subrc <> 0.
    FORMAT COLOR 6 ON.
    write : / 'Problem whiling reading characterstics for class '
       ,cl_name ,' of type ',cl_type.
    FORMAT COLOR OFF.
     "error handling...
  endif.

endform.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.