3 Replies Latest reply: Aug 18, 2010 9:26 AM by 843789 RSS

    StringIndexOutOfBoundsException: String index out of range: 185

    843789
      Hi Guys,

      I am getting below mentioned runtime error in my java program.

      The message is: Exception:[java.lang.StringIndexOutOfBoundsException: String index out of range: 185] in class com.sap.xi.tf._MM_RSPD_INFILE_RSPD_OUTFILE_ method SplitRow$[]

      I am writing this program in SAP PI for a User defined function.

      Structure of my file is,

      String contractNo = x.substring(0,10);     //1-10 SAP contract reference
      String quantity = x.substring(10,25);     //11-25 Quantity
      String price = x.substring(25,40);     //26-40 Price
      String delperiod = x.substring(40,46);     //41-46 Delivery period e.g. YYYYMM
      String condate = x.substring(46,54);     //47-54 Contract date e.g. YYMMDD
      String shipwts = x.substring(54,57);     //55-57 Shipped weights e.g. DWT/EWT
      String mtype = x.substring(57,58);     //58 Market Type D/E
      String cif = x.substring(58,73);     //59-73 CIF price
      String comtype = x.substring(73,77);     //74-77 comtype e.g. ZRAW
      String rejreason = x.substring(77,97);     //78-97 Reject reason
      String type = x.substring(97,98);     //98 Type, A =create, B=amend, C= delete
      String usrname = x.substring(98,110);     //99-110 User Name
      String impdate = x.substring(110,118);     //111-118 Date, e.g. YYYYMMDD, imported as Quote date
      String imptime = x.substring(118,124);     //119-124 Time e.g. HHMMSS, imported as Quote time HH:MM
      String vafrdate = x.substring(177,185);     //177,185 Date, e.g. YYYYMMDD, valid from date

      Example Lines of code used for offsetting,

      if ( delperiod.substring(4,6).equals("01") && vafrdate.substring(181,185).equals("0101") )

      Structure of input file,

      0040000305 -153000.000 20.00020110120100817DWTD 0.000ZRAW ANHUK 20100817165602 20110101

      Guys,
      any idea, what mistake i am doing in above code(probably some offsetting mistake).....

      regards.
      santosh.