Skip to Content
0
Former Member
Dec 28, 2005 at 06:48 AM

split field into two variables

583 Views

Hi,

I am comparing a field with two variables where the first four characters of the variable are equal to var1 and rest of the characters are equal to var2.

TYPES: BEGIN OF T_ZWIPSTAT,
        LOTNUM TYPE ZMES_LOT,          "MES LOT NUMBER
      ORDERNUM TYPE AUFNR,             "ORDER NUMBER
     OPR_DESCP TYPE ZOPRDESCP,         "OPERATION DESCRIPTION
     ROUTE(36) TYPE C,
    OPR_DES(4) TYPE C,
       END OF T_ZWIPSTAT.


SELECT LOTNUM
           ORDERNUM
           OPR_DESCP
           FROM ZWIPSTAT
           INTO TABLE  I_ZWIPSTAT1
           FOR ALL ENTRIES IN I_ZLHSTOCKOVERVIEW
           WHERE WERKS = I_ZLHSTOCKOVERVIEW-WERKS
             AND ORDERNUM = I_ZLHSTOCKOVERVIEW-ORNUM.
ENDIF.


LOOP AT I_ZWIPSTAT1 INTO IS_ZWIPSTAT1.

  V_INDEX = SY-TABIX.

    IF NOT IS_ZWIPSTAT1-OPR_DESCP+0(4) IN S_OPNUM AND
       NOT IS_ZWIPSTAT1-OPR_DESCP+4(36) IN S_OPRDES.

       DELETE I_ZWIPSTAT1 INDEX V_INDEX.
       ELSE.
       MOVE I_ZWIPSTAT1 TO I_ZWIPSTAT.

    ENDIF.
ENDLOOP.

with the above code i have only those records which i need in the internal table.

My requirement is to split the field ""OPR_DESCP"" and get the first 4 charaters to ""opr_des"" and the rest of the characters to ""route"" as defined in the types statement.

Can any one pls tell how write the code for this and where should I write that.