How to use SPLIT statements in SAP

I have a Variable which stores two field values like Purchase Order No and Date now I want to display this Value correctly from that Variable
e.g VAR1 = PONO/Date
How to print PONO on one line and Date on the other line from the VARIABLE VAR1.

Hi Nandan,
There are different ways to do this.
Suppose your variable contains always a fixed length of two other values like PO number an Date.
DATA: v_pono         TYPE ebeln,
      v_date         TYPE sydatum,
      v_variable(18) TYPE C.
v_variable = '000001234520050201'.
You can then read the parts like this:
v_pono = v_variable+000(010).
v_date = v_variable+010(008).
Suppose your variable contains always a variable length of two other values like PO number an Date.
DATA: v_pono         TYPE ebeln,
      v_date         TYPE sydatum,
      v_variable(20) TYPE C,
      v_table        LIKE v_variable OCCURS 0.
v_variable = '12345/20050201'.
You can then read the parts like this:
SPLIT v_variable AT '/' INTO TABLE v_table.
READ TABLE v_table INTO v_pono INDEX 1.
READ TABLE v_table INTO v_date INDEX 2.
Or you can use it like this:
SPLIT v_variable AT '/' INTO v_pono v_date.
Hope this gives you some clues.
Regards,
Rob.

Similar Messages

  • How to use perform statements in sap scripts

    how to use perform statements in sap scripts . and pls send me one progam for this
    thnaks
    raja

    Hi Raja,
    <b>PERFORM</b> key work is used to include subroutine in sapscript form...
    But the processing is lttle bit different form the one we use in ABAP.
    Here the paramters passed to form is stored in internal table of name-value table. there are two table one for inbound parameter and other for outbound parameters.
    Check out the example below to see how this is used..
    <b>Definition in the SAPscript form:</b>
    /: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
    /: USING &PAGE&
    /: USING &NEXTPAGE&
    /: CHANGING &BARCODE&
    /: ENDPERFORM
    / &BARCODE&
    <b>Coding of the calling ABAP program:</b>
    REPORT QCJPERFO.
    FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY
    OUT_PAR STRUCTURE ITCSY.
    DATA: PAGNUM LIKE SY-TABIX, "page number
    NEXTPAGE LIKE SY-TABIX. "number of next page
    READ TABLE IN_PAR WITH KEY ‘PAGE’.
    CHECK SY-SUBRC = 0.
    PAGNUM = IN_PAR-VALUE.
    READ TABLE IN_PAR WITH KEY ‘NEXTPAGE’.
    CHECK SY-SUBRC = 0.
    NEXTPAGE = IN_PAR-VALUE.
    READ TABLE OUT_PAR WITH KEY ‘BARCODE’.
    CHECK SY-SUBRC = 0.
    IF PAGNUM = 1.
    OUT_PAR-VALUE = ‘|’. "First page
    ELSE.
    OUT_PAR-VALUE = ‘||’. "Next page
    ENDIF.
    IF NEXTPAGE = 0.
    OUT_PAR-VALUE+2 = ‘L’. "Flag: last page
    ENDIF.
    MODIFY OUT_PAR INDEX SY-TABIX.
    ENDFORM.
    Hope this is clear to understand...
    Enjoy SAP.
    Pankaj Singh.

  • How to use IF Conditon in SAP Scripts?

    Hi Guys,
                   I am having adoubt how to use IF conditon with multiple variables in SAp Scripts
    for ex If a>b and a>c and a>d
             Elseif b>a and b>c and b> d.
             Elseif .....
              endif.
              How to use above example in SAP Scripts.
    thanks,
    Gopi.

    hi Gopi,
    it is almost the same as normal ABAP, you only have to use & before and after the variable and the variable has to be in capitals and you have to make the line as command ( /: before the line )
    IF &A& > &B& AND ...
    text to print
    ELSEIF ...
    text to print
    ENDIF.
    hope this helps
    ec

  • How to use the Variants in SAP Transportation and what is its use ?

    Hi experts,
    How to use the Variants in SAP Transportation and what is its use & How to create a variant in SAP ?
    Can anybody answer this ?
    Regards,
    Shakti

    Hi,
    If you are asking about "slection vairants" in SPRO settings of "shipment cost document" then
    When it is activated,
    each user can have his own slecetion  and list criteria for
    1. List shippment costs:calculation
    2. List shippment costs: settlement
    This can be directly saved from VI01 screen by the user.
    from environment> lists
    This is user specific only.
    Hope this helps.
    Regards,
    Sharan

  • How to debugg particular statement in sap script

    hi friends,
    i want to know How to debugg particular statement in sap script.
    plz reply.
    thanks in advance,
    regards
    bhaskar

    hi
      execute rstxdbug to activate script debugger...once the driver program reaches open_form, a popup box will come where u can mention the name of a command, call functinon, text element, etc to place a break point...once it gets into the debugging mode, double click on any line to set a break point, after that pressing f8 will get you to that line
    if helpful, reward
    Sathish. R

  • How to use union statement with declare & set function?

    Hi Experts,
            i  have small query about how to use union statement with declare & set function?
    Example as below :
    DECLARE @name AS date
    Declare @name2  AS date
    /* SELECT FROM [2013].[dbo].[OINV] T0 */
    /* WHERE */
    SET @name = /* T0.DocDate */ '[%1]'
    SET @name2 = /* T0.DocDate */ '[%2]'
    select  '2013',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
    datediff(dd,t3.DocDate,t1.Docdate) as Days
    from 2013.dbo.orct t1
    inner join 2013.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
    left join 2013.dbo.oinv t3 on
    t3.docentry = t2.baseAbs
    inner join 2013.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
    inner join [2013].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
    where t2.DcntSum <> 0.000000 and t3.DocDate between [%1] and [%2]
    Union
    /* SELECT FROM [2014].[dbo].[OINV] T0 */
    /* WHERE */
    SET @name = /* T0.DocDate */ '[%1]'
    SET @name2 = /* T0.DocDate */ '[%2]'
    select  '2014',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
    datediff(dd,t3.DocDate,t1.Docdate) as Days
    from 2014.dbo.orct t1
    inner join 2014.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
    left join 2014.dbo.oinv t3 on
    t3.docentry = t2.baseAbs
    inner join 2014.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
    inner join [2014].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
    where t2.DcntSum <> 0.000000 and t3.DocDate between [%1] and [%2]

    You have to create stored procedure in SQL only .
    Like u must have create for Crystal .
    You can execute procedure in query manager but you have to enter parameter manually..
    example
    Exec @Test '20140101' '20140501'
    Every time user has to enter it manually in yyyymmdd format in case of date parameters.
    Example
    Create Proc [@Test]
    as begin
    DECLARE @name AS date
    Declare @name2  AS date
    /* SELECT FROM [2013].[dbo].[OINV] T0 */
    /* WHERE */
    select  '2013',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
    datediff(dd,t3.DocDate,t1.Docdate) as Days
    from 2013.dbo.orct t1
    inner join 2013.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
    left join 2013.dbo.oinv t3 on
    t3.docentry = t2.baseAbs
    inner join 2013.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
    inner join [2013].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
    where t2.DcntSum <> 0.000000 and t3.DocDate between @Name and @Name2
    Union
    /* SELECT FROM [2014].[dbo].[OINV] T0 */
    /* WHERE */
    select  '2014',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
    datediff(dd,t3.DocDate,t1.Docdate) as Days
    from 2014.dbo.orct t1
    inner join 2014.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
    left join 2014.dbo.oinv t3 on
    t3.docentry = t2.baseAbs
    inner join 2014.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
    inner join [2014].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
    where t2.DcntSum <> 0.000000 and t3.DocDate between
    between @Name and @Name2
    end

  • How to use CASE statement in WDA

    Hi All,
       Can any one Please expain me ' How to use CASE statement in Web dynpro ABAP? '
      Please give me an example also.
    Thanks in Advance !

    Hi,
    The usage of case statement in webdynpro is same as used in general ABAP.
    Data: l_id type string.
    l_id = wdevent->get_string( 'ID' ).
    case l_id.
    when 'BTN1'.
    when 'BTN2'.
    when 'OTHERS'.
    endcase.
    Regards,
    Radhika.

  • How to use collect statement for below

    data : begin of itab,
             n(3) type c,
          n1 type n,
          k(5) type c,
          end of itab.
    select n n1 from into itab table /zteest.
    *internal table has
    n      n1    k
    gar    100  uji
    hae    90   iou
    gar    90   uji
    hae    87   iou
    I want
    gar 190
    hae 177
    How to use collect statement as n1 is n ..?
    let me know..
    Thanks

    try this..
    DATA : BEGIN OF itab OCCURS 0,
    n(3) TYPE c,
    n1(3) TYPE p DECIMALS 2,
    k(5) TYPE c,
    END OF itab.
    itab-n = 'gar'.
    itab-n1 = 100.
    itab-k = 'uji'.
    COLLECT itab .CLEAR itab.
    itab-n = 'hae'.
    itab-n1 = 90.
    itab-k = 'iou'.
    COLLECT itab .CLEAR itab.
    itab-n = 'gar'.
    itab-n1 = 90.
    itab-k = 'uji'.
    COLLECT itab .CLEAR itab.
    itab-n = 'hae'.
    itab-n1 = 87.
    itab-k = 'iou'.
    COLLECT itab .CLEAR itab.

  • How to use multiple statements inside the "THEN" block of CASE statement?

    Below is the code:
    SET @strTempString = case @strKeyMode
    WHEN 'AUTO/CYCLE'
    THEN  @strRefID + '|' + @strRetID
    WHEN 'CYCLE'
    THEN  @strRefID + '|' + @strRetID
    WHEN 'COMMERCIAL'
    THEN  @strRefID + '|' + @strRetID
    WHEN 'ISNAP'
    THEN  set @strFName = ltrim(rtrim((Left(dbo.CleanTheStringAdv(@strFName + '  ', 2) + '  ', 2))))
    '' + @strRefID + '|' + @strLName + '|' + @strFName + '|' + @strZIPorPolType
    WHEN 'ASNAP'
    THEN  @strRefID + '|' + @strRetID
    WHEN 'MOAT'
    THEN  @strRefID + '|' + @strRetID
    else '0'
    end 
    The first 3 conditions are understandable. How to use multiple statements in 4th case?
    Here I first want to set the value as:
    set @strFName = ltrim(rtrim((Left(dbo.CleanTheStringAdv(@strFName + '  ', 2) + '  ', 2))))
    and then return the string '' + @strRefID + '|' + @strLName + '|' + @strFName + '|' + @strZIPorPolType to @strTempString. 
    Please help me remove the syntax errors.
    Thanks in advance.

    Try below SQL
    DECLARE @strKeyMode varchar(20) = 'ISNAP'
    DECLARE @SQL VARCHAR(MAX)
    DECLARE @strRefID int=1
    DECLARE @strRetID INT=2
    --FIRST WAY
    IF @strKeyMode ='AUTO/CYCLE'
    SELECT CAST(@strRefID as varchar(10))
    ELSE IF @strKeyMode ='CYCLE'
    SELECT @sql = CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))
    ELSE IF @strKeyMode='ISNAP'
    SELECT @sql = CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))+'test'+'abc'
    ELSE
    SELECT @SQL='ABC'
    print @sql
    ----SECOND WAY
    SELECT @SQL = CASE @strKeyMode
    WHEN 'AUTO/CYCLE' THEN CAST(@strRefID as varchar(10))
    WHEN 'CYCLE' THEN CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))
    WHEN 'ISNAP' THEN CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))+'test'+'abc'
    ELSE 'No Record'
    END
    PRINT (@SQL)
    --Prashanth

  • Workflow Components : how to use SPLIT and JOIN ?

    Dear all,
    Because a Transition does not have any return of result, do you know how to use SPLIT and JOIN components ?
    <activity name='"xyz">
    <Transition to='act1'>
    </Transition>
    <Transition to='act2'>
    </Transition>
    </activity>
    In this above example, the second transition towards act2 is never called (i.e. there is no condition for the first transition) because there is no return of result for the first transition.
    Unfortunately, I didn't find any documentation about the SPLIT and JOIN workflow components. Do you have some information about these components ? How to use them ?
    Thanks a lot.

    <activity name='"xyz" andSplit='true'>
    <Transition to='act1'>
    </Transition>
    <Transition to='act2'>
    </Transition>
    </activity>
    The "andSplit='true'" will cause it transition to both act1 and act1.

  • How to use " PERFORM ", STATEMENT WITH OFFSET

    hI,
    How we use Perform statement with offset, like
      Example:   " PERFORM READ_SEGRELEASE USING INT_EDIDC+11."
    My requirement is to use Perform with Automatic length declaration.
    Automatic length declaration in PERFORM statement
    Kindly Explain and Provide some Example programm written in this situation.
    Thanks,
    P.N.Kumar

    Hiere is an example of what you probably require:
    DATA:
    lv_offset        TYPE syoffi,
    lv_length        TYPE flength,
    lv_field          TYPE string.
    lv_field  = 'This is my value: hello world'.
    lv_length = 5.
    lv_offset = 18.
    PERFORM read_segrelease USING lv_field
                                                            lv_length
                                                            lv_offset.
    *&      Form  READ_SEGRELEASE
    *       text
    *      -->P_LV_FIELD  text
    *      -->P_LV_LENGTH  text
    *      -->P_LV_OFFSET  text
    FORM read_segrelease USING    p_lv_field         TYPE string
                                                         p_lv_length      TYPE flength
                                                         p_lv_offset      TYPE syoffi.
      DATA:
      lv_result    TYPE string.
      lv_result = p_lv_field+p_lv_offset(p_lv_length).
      WRITE: / lv_result.
    ENDFORM.                    " READ_SEGRELEASE

  • How to use collect statement

    hi everybody,
    how to use collect statement to get the total amount paid to different vendor payments 
    data : begin of wa occurs 0,
            bukrs type bsak-bukrs,
            lifnr type bsak-lifnr,
            land1 type lfa1-land1,
            name1 like lfa1-name1,
            dmbtr like bsak-dmbtr,
            count type i value 0,
            tot_vend  type i,
            vend type i.
    data :end of wa.
    data : itab like table of wa.
      select distinct bukrs lifnr waers from bsak into
    corresponding fields of wa
              where bukrs in s_bukrs
              and   lifnr in s_lifnr
              and   bschl in s_bschl.
    i want the total amount paid according to vendor i am  using this way but i am not getting
      loop at itab into wa.
    wa-dmbtr = bsak-dmbtr.
    collect wa-dmbtr into itab.
    modify itab from wa transporting dmbtr.
    i am unalbe to get it
    can anybody help me regarding this if possible with example.
    thanks in advance,
    regards,
    venu.

    Hi Venu,
    types: BEGIN OF ty,
            NAME(20),
            SALES TYPE I,
          END   OF ty.
    data : itab type standard table of ty,
    itab1 type standard table of ty,
    wa type ty,
    wa1 type ty.
    wa-NAME = 'Duck'.  wa-SALES = 10.
    append wa to itab.
    wa-NAME = 'Tiger'. wa-SALES = 20.
    append wa to itab.
    wa-NAME = 'Duck'.  wa-SALES = 30.
    append wa to itab.
    loop at itab into wa.
    wa1 = wa.
    collect wa1 into itab1.
    endloop.
    loop at itab1 into wa1.
    write : / wa1-name , wa1-sales.
    endloop.
    COLLECT is used to create unique or compressed datsets. The key fields are the default key fields of the internal table itab .
    If you use only COLLECT to fill an internal table, COLLECT makes sure that the internal table does not contain two entries with the same default key fields.
    <b>If, besides its default key fields, the internal table contains number fields (see also ABAP/4 number types ), the contents of these number fields are added together if the internal table already contains an entry with the same key fields.</b>
    If the default key of an internal table processed with COLLECT is blank, all the values are added up in the first table line.
    In the program you mentioned yesterday,I am not able to get the logic since many lines are commented.

  • How to use split screen on a mac like on windows 7

    how to use split screen on a mac like on windows 7

    It does not function the same as windows, in that it does not have an automatic snap function.  You can put multiple apps up side by side though.  You might want to consider using Spaces instead.

  • How to import bank statements in SAP 2007A

    Hi All,
    I was wondering if there are different ways to import a bank statement. My customer is wanting to do a external reconciliation on a bank statement, but they are unsure on how to import their statement. Any suggestions.
    Best Regards,
    Jeff Haldeman
    Support One

    You can use the 'oBankPages.xlt' file available in the following folder
    C:\Program Files\SAP\Data Transfer Workbench\Templates\Templates\oBankPages

  • How to use "SPLIT" on the string

    Hi,
    i am using split on an internal table  where the field in the table is a string.
    the following is the code.
    TYPES:BEGIN OF IT_MAT,
         MATERIAL TYPE STRING,
         END OF IT_MAT.
    DATA IT_MATERIAL TYPE IT_MAT OCCURS 0
         WITH HEADER LINE.
    and after populating the internal table with some string values
    i am using this statement:-
    split it_material at '|' into it_result_table-field1  w_remaining.
    Here i am getting an error message saying that it_material must be a character-type data object.
    please help me out in this
    thanks
    kumar

    Hi kumar,
    Please check this thread by clicking on the below link. It will solve ur problem.
    Re: how to Split a String ?
    Regards,
    KK

Maybe you are looking for