How to Get the Version Value When I Print the PO

Need to display the Version of PO in the printout. But the table ekko or erev doesn't contain the version value at runtime. 

The following example code will get the version no. in PO  :-

referesh : erevitem.
clear : erevlines.

  SELECT SINGLE * FROM cdpos
  WHERE objectid = ebeln AND
        value_old = 'G' AND
        value_new = 'B'.

  IF sy-subrc EQ 0.

    erevlines = erevlines + 1.

  ELSE.

    erevlines = 0.

  ENDIF.

SELECT * FROM nast
  INTO CORRESPONDING FIELDS OF TABLE itab_nast
  WHERE objky = ebeln AND
        vstat NE '0'.

  CLEAR itab_nast.
  SORT itab_nast DESCENDING BY erdat eruhr.

  READ TABLE itab_nast INDEX 1.

  IF sy-subrc EQ 0.
    IF itab_nast-vstat NE '0'.

      LOOP AT l_doc-xekpo INTO tekpo.

        CALL FUNCTION 'ME_CHANGEDOC_SELECT'
          EXPORTING
            i_document_category      = pekko-bstyp
            i_document_number        = ebeln
            i_document_item          = tekpo-ebelp
*  I_DATE_START              =
*  I_TIME_START              =
*  I_DATE_END                =
*  I_TIME_END                =
*  I_USERNAME                =
*  I_ALL_ITEMS              =
*  I_GRIDHANDLE              =
*  I_REVISIONLIST            =
*  I_ARCHIVE_HANDLE          =
        IMPORTING
*  E_LINES                  =
          e_outtab                  = imecdgrid.


        it_mecdgrid[] = imecdgrid[].

        LOOP AT it_mecdgrid INTO wa_mecdgrid WHERE tabkey+13(5) = tekpo-ebelp.


          IF wa_mecdgrid-fname = 'MENGE'.

            itab_po_change-matnr = tekpo-matnr.
            itab_po_change-text = '***** Quantity Change ******'.
            erevlines = erevlines + 1.


            APPEND itab_po_change.

          ENDIF.

          IF wa_mecdgrid-fname = 'NETWR'.

            itab_po_change-matnr = tekpo-matnr.
            itab_po_change-text = '***** Price Change ******'.
            erevlines = erevlines + 1.


            APPEND itab_po_change.


          ENDIF.


        ENDLOOP.


      ENDLOOP.

      SORT itab_po_change BY matnr text.

      LOOP AT itab_po_change.

        DELETE ADJACENT DUPLICATES FROM itab_po_change COMPARING matnr text.

      ENDLOOP.


    ENDIF.
  ENDIF.


  SELECT * FROM erev INTO CORRESPONDING FIELDS OF TABLE erev WHERE edokn = pekko-ebeln.

  SORT erev BY revno DESCENDING.



  LOOP AT erev.
    MOVE-CORRESPONDING erev TO erevitem.
    APPEND erevitem.
  ENDLOOP.

  DESCRIBE TABLE erevitem LINES erevlines.
  IF erevlines = 1.
    CLEAR erevitem[].
    erevlines = 0.
  ENDIF.
*
**  erevlines = erevlines - 1.
*
  DELETE erevitem WHERE revno = 0.
  CLEAR erevlines.
  DESCRIBE TABLE erevitem LINES erevlines.

call function fm_name
exporting 
  erevlines  = erevlines

tables
  erev      = erevitem
endform.


IN SSF :

loop at erev into wa_erev where erevlines > '0'.


wa_erevlines-revno(.0)  for version no.
wa_erevlines-txz01 for version text
ABAP Tips by : Ashu gupta

Fast Links:
Get help for your ABAP problems
Do you have a ABAP Question?

SAP Books
SAP Certification, Functional, Basis Administration and ABAP Programming Reference Books

ABAP Tips
ABAP Forum for Discussion and Samples Program Codes for Abapers

Best regards,
SAP Basis, ABAP Programming and Other IMG Stuff
http://www.erpgreat.com

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.