Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

open items for purchase order its very urgent

0 Kudos

hi

my requirement is to write extract program for purchase order(me21) to extract only open items.

please provide sample code its very urgent.

thanks in advance.

points will be rewarded.

thanks

hari prasad reddy

4 REPLIES 4

Former Member
0 Kudos

Hello,

<b>


Check the field EKPO-ELIKZ = SPACE.

if ELIKZ is space then the item is having open quantity.

</b>

If useful reward.

Vasanth

Former Member
0 Kudos

Start with this:


DATA: his_index              LIKE sy-tabix,
      menge                  LIKE ekpo-menge.

* Is the PO complete?

* If a PO line item has "Final Invoice" or "Deleted" checked
* off, it is complete.

CLEAR: final_invoice,
       deleted,
       completed.

po_paid = 'X'.     "Assume it's paid

SELECT  ebeln ebelp menge
  FROM  ekbe                    "Purchasing Document History table
  INTO  CORRESPONDING FIELDS OF his_data
  WHERE ebeln = ekko_int-ebeln
    AND vgabe = '2'.

  COLLECT: his_data.

ENDSELECT.

LOOP AT ekpo_int WHERE ebeln = ekko_int-ebeln.

  IF ekpo_int-erekz = 'X'.
    final_invoice = 'X'.
  ENDIF.
  IF ekpo_int-loekz = 'L'.
    deleted = 'X'.
  ENDIF.

  IF deleted       <> 'X' AND
     final_invoice <> 'X'.

    CLEAR menge.
    READ TABLE his_data WITH KEY
      ebeln = ekpo_int-ebeln
      ebelp = ekpo_int-ebelp
      BINARY SEARCH.
    IF sy-subrc = 0.
      his_index = sy-tabix.
      DO.
        IF sy-subrc = 0.
          IF his_data-ebeln = ekpo_int-ebeln AND
              his_data-ebelp = ekpo_int-ebelp.
            his_index = his_index + 1.
            menge = menge + his_data-menge.
            READ TABLE his_data INDEX his_index.
          ELSE.
            EXIT.
          ENDIF.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
    ENDIF.
    IF menge <> ekpo_int-menge.
      CLEAR po_paid.
      EXIT.
    ENDIF.
  ENDIF.
ENDLOOP.

IF po_paid          = 'X' OR
   deleted          = 'X' OR
   final_invoice    = 'X'.                   " Was 'OR'
  completed = 'X'.
ELSE.
  CLEAR completed.
ENDIF.

Rob

Former Member
0 Kudos

if the purchase order is not complete or deleted you can check table eket for every po Item. if wemng is 0 you can add menge ... if wemng is not 0 then you have to subtract menge from wemng and add it to the open quantity.

loop at every open purchase order item.

SELECT eketebeln eketebelp eketetenr eketmenge eket~wemng

INTO TABLE it_eket FROM eket

WHERE eket~ebeln = ekpo-ebeln AND

eket~ebelp = ekpo-ebelp.

LOOP AT it_eket INTO wa_eket.

IF wa_eket-wemng = 0.

w_ekpo_menge = w_ekpo_menge + wa_eket-menge.

ELSE.

w_ekpo_menge = w_ekpo_menge + ( wa_eket-menge - wa_eket-wemng ).

ENDIF.

ENDLOOP.

ENDSELECT.

endloop.

Former Member
0 Kudos

check the below report :

REPORT ZMM_OPEN_PO_REPORT no standard page heading

line-size 255

message-id zwave.

======================================================================

  • *

  • Program Name : ZMM_OPEN_PO_REPORT *

  • *

  • Description : This report displays all Open PO Items and output *

  • would be PO Number,Material number and so on *

  • *

  • Author : Seshu *

  • Date : 01/24/2007 *

  • *

----


  • MODIFICATION HISTORY *

----


  • DATE | AUTHOR | CHANGE # | DESCRIPTION OF MODIFICATION *

--


|
|

|
--

  • 01/24/07| Seshu | DEVK921979 | Initial *

************************************************************************

************************************************************************

    • D A T A D E C L A R A T I O N P A R T ***

************************************************************************

  • type-pools

type-pools : slis.

  • Tables

tables : ekko, " Purchase order Header

ekpo, " Purchase order Item

marc. " Material with Plant data

  • Internal table for output.

data : begin of i_output occurs 0,

ebeln like ekko-ebeln,

matnr like ekpo-matnr,

end of i_output.

  • ALV Data declaration.

data : v_repid like sy-repid.

  • ALV Function Module Variables

DATA: gs_layout type slis_layout_alv,

g_exit_caused_by_caller,

gs_exit_caused_by_user type slis_exit_by_user.

DATA: gt_fieldcat type slis_t_fieldcat_alv,

gs_print type slis_print_alv,

gt_events type slis_t_event,

gt_list_top_of_page type slis_t_listheader,

g_status_set type slis_formname value 'PF_STATUS_SET',

g_user_command type slis_formname value 'USER_COMMAND',

g_top_of_page type slis_formname value 'TOP_OF_PAGE',

g_top_of_list type slis_formname value 'TOP_OF_LIST',

g_end_of_list type slis_formname value 'END_OF_LIST',

g_variant LIKE disvariant,

g_save(1) TYPE c,

g_tabname_header TYPE slis_tabname,

g_tabname_item TYPE slis_tabname,

g_exit(1) TYPE c,

gx_variant LIKE disvariant.

data : gr_layout_bck type slis_layout_alv.

  • Ranges

ranges r_eindt for eket-eindt.

initialization.

v_repid = sy-repid.

start-of-selection.

  • Get the data from EKKO ,EKPO and MARC Table

perform get_data_tables.

end-of-selection.

  • display the data in the form of ALV

perform display_data.

&----


*& Form get_data_tables

&----


  • Get the data from EKKO,EKPO and MARC Table

----


FORM get_data_tables.

clear : i_output.

refresh : i_output.

  • fill the dates in ranges

r_eindt-low = sy-datum - 7.

r_eindt-high = sy-datum + 14.

r_eindt-option = 'BT'.

r_eindt-sign = 'I'.

append r_eindt.

  • Get the data from EKKO,EKPO and EKET Tables

select aebeln bmatnr into table i_output

from ekko as a inner join

ekpo as b on aebeln = bebeln

inner join marc as c on cmatnr = bmatnr

inner join mara as d on dmatnr = bmatnr

inner join eket as e on eebeln = aebeln

and eebelp = bebelp

where c~beskz = 'E'

and c~werks = '1000'

and d~mtart = 'FERT'

and b~loekz = space

and b~elikz = space

and e~eindt in r_eindt.

if sy-subrc ne 0.

message e000(zwave) with 'No open purchase order found'.

endif.

ENDFORM. " get_data_tables

&----


*& Form display_data

&----


  • text

----


FORM display_data.

  • Fill the Fiedlcat

PERFORM fieldcat_init using gt_fieldcat[].

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = g_user_command

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

  • IS_LAYOUT = gr_layout_bck

IT_FIELDCAT = gt_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = g_save

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_ADD_FIELDCAT =

  • IT_HYPERLINK =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IT_EXCEPT_QINFO =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = i_output

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " display_data

&----


*& Form fieldcat_init

&----


  • text

----


  • -->P_GT_FIELDCAT[] text

----


FORM fieldcat_init USING e01_lt_fieldcat type slis_t_fieldcat_alv.

DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

  • Purchase order number

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'EBELN'.

LS_FIELDCAT-ref_fieldname = 'EBELN'.

LS_FIELDCAT-ref_tabname = 'EKKO'.

LS_FIELDCAT-TABNAME = 'I_OUTPUT'.

ls_fieldcat-seltext_L = 'Purchase Order'.

ls_fieldcat-seltext_M = 'Purchase Order'.

ls_fieldcat-seltext_S = 'Purchase Order'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

  • Material #

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'MATNR'.

LS_FIELDCAT-ref_fieldname = 'MATNR'.

LS_FIELDCAT-ref_tabname = 'EKPO'.

LS_FIELDCAT-TABNAME = 'I_OUTPUT'.

ls_fieldcat-seltext_L = 'Material'.

ls_fieldcat-seltext_M = 'Material'.

ls_fieldcat-seltext_S = 'Material'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

ENDFORM. " fieldcat_init