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

fiscal year/fiscal period

Hi Friends,

Can you please provide me an optimized select for the following case.

For Last posting FY/period: for each G/L account, Company code combination, determine the MAX (Doc. No) in BSEG, and look up the corresponding document in BKPF table to get the last posting FY/Period.

If you want any more details for the select, Please let me know.

Thanks,

Suryaprakash Gaddam.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 30, 2006 at 02:26 PM

    i don't know what you really need but any way don't

    use bseg for your select .

    use secondary tables ( bsik/bsak , bsid/bsad , bsis/bsas).

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 30, 2006 at 02:49 PM

    hi,

    try:

    TABLES: bseg, skc1a.
    SELECT-OPTIONS: bukrs FOR bseg-bukrs,
                    konto FOR bseg-hkont.
    PARAMETERS gjahr TYPE bseg-gjahr.
    <i>data cnt like sy-tabix.</i>
    DATA soll LIKE skc1a-um01s.
    DATA haben LIKE skc1a-um01s.
    DATA: BEGIN OF itab OCCURS 0,
            bukrs TYPE skc1c-bukrs,
            saknr TYPE skc1c-saknr,
            gjahr TYPE skc1c-gjahr,
            buper TYPE bkpf-monat,
          END OF itab.
    DATA htabix LIKE sy-tabix.
    
    
    START-OF-SELECTION.
    
      SELECT bukrs saknr   FROM  skb1
                               APPENDING CORRESPONDING FIELDS OF TABLE itab
             WHERE  bukrs IN bukrs
             AND    saknr IN konto.
    
      LOOP AT itab.
        htabix = sy-tabix.
        itab-gjahr = gjahr.
        CALL FUNCTION 'READ_SKC1A'
             EXPORTING
                  xbukrs         = itab-bukrs
                  xgjahr         = gjahr
                  xgsber         = space
                  xsaknr         = itab-saknr
             IMPORTING
                  xskc1a         = skc1a
             EXCEPTIONS
                  key_incomplete = 1
                  not_authorized = 2
                  not_found      = 3
                  OTHERS         = 4.
    
        CHECK sy-subrc = 0.
        <i>cnt = 17.</i>  
      DO 16 TIMES VARYING
                            soll FROM skc1a-um16s NEXT skc1a-um15s
                   VARYING haben FROM skc1a-um16h NEXT skc1a-um15h.
    
          <i>add -1 to cnt. </i>     
      IF soll <> 0 OR haben <> 0.
            MOVE <i>cnt</i> TO itab-buper.
            MODIFY itab INDEX htabix.
            EXIT.
          ENDIF.
        ENDDO.
    
        WRITE : / itab-bukrs, itab-saknr, itab-gjahr, itab-buper.
    
    
      ENDLOOP.

    Andreas

    pls reward points for useful answers

    Message was edited by: Andreas Mann

    Programm was modified (see text in italian)

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 30, 2006 at 02:31 PM
    data : begin of i_gl occurs 0,
             cc type bukrs,
             gl type hkont,
           end of i_gl.
    data : begin of i_bsis occurs 0,
             bukrs type bukrs,
             hkont type hkont,
             belnr type belnr,
           end of i_bsis.
    data : max_belnr type belnr.
    
    select bukrs hkont belnr from bsis into table i_bsis
           for all entries in i_gl
           where bukrs = i_gl-cc
             and hkont = i_gl-hkont.
    if sy-subrc = 0.
      sort i_bsis by bukrs hkont belnr descending.
    endif.
    loop at i_gl.
      at new gl.
        read i_bsis with key bukrs = i_gl-cc 
                             hkont = i_gl-gl binary search.
        if sy-subrc = 0.
          max_belnr = i_bsis-blnr.
          { With this BELNR proceed to the senario u want here }
        endif.
      endat. 
    endloop.

    Regards,

    Sreedhar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 30, 2006 at 02:40 PM

    hi

    If you need to check only G/L accounting use the table BSAK and BSAS, here u can get the last number and posting date.

    But where do u need to insert this control?

    Usually it starts from document type and then it founds out the number range from it.

    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.