BDC  for purchase order

Hi guys I have written the following program to upload the purchase order data by using BDC call transaction method, now I want to write whatever is in the message table, I mean the errors if there are any and the other required fields. So can you please help me in writing that :
Thanks
Rajeev Gupta
*& Report  ZBDC_PURCHASEORDER                                          *
REPORT  zbdc_purchaseorder                      .
Definition of Structures *
DATA: bdctab LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF itab OCCURS 0,
        vend_no(10),
        ord_typ(2),
        date(8),
        purch_org(4),
        purch_grp(3),
        plant(4),
        sloc(4),
        mat_grp(3),
        mat_no(18),
        quant(13),
        inc_term(3),
        inc_inf(28),
      END OF itab.
DATA: itab2 LIKE itab OCCURS 0 WITH HEADER LINE.
Definition of Variables *
DATA: v_tabix LIKE syst-tabix,
      v_tabix2(2) TYPE n,
      v_ekorg LIKE ekko-ekorg,
      v_werks LIKE ekpo-werks,
      v_lifnr LIKE ekko-lifnr,
      v_bednr LIKE ekpo-bednr,
      v_index LIKE syst-index,
      l1 LIKE syst-tabix,
      c_tabix(2),
      v_mat_no(18),
      v_mat_quant(16).
Definition of Constants *
START-OF-SELECTION *
START-OF-SELECTION.
  PERFORM get_data.
  PERFORM create_bdcdata.
END-OF-SELECTION.
*&      Form  get_data
      text
-->  p1        text
<--  p2        text
FORM get_data .
  CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
      filename                = 'C:\Documents and Settings\ekansh\Desktop\purc_order.txt'
      filetype                = 'DAT'
    TABLES
      data_tab                = itab
    EXCEPTIONS
      conversion_error        = 1
      file_open_error         = 2
      file_read_error         = 3
      invalid_table_width     = 4
      invalid_type            = 5
      no_batch                = 6
      unknown_error           = 7
      gui_refuse_filetransfer = 8
      OTHERS                  = 9.
  itab2[] = itab[].
*write : / itab-vend_no.
ENDFORM.                    " get_data
*&      Form  create_bdcdata
      text
-->  p1        text
<--  p2        text
FORM create_bdcdata .
  DESCRIBE TABLE itab LINES l1.
  LOOP AT itab.
    v_tabix = syst-tabix.
    IF v_tabix = 1.
      MOVE v_tabix TO v_tabix2.
      PERFORM bdc_dynpro USING:
        'X'  'SAPMM06E'        '0100',
        ''   'BDC_OKCODE'      '/00',
        ''   'EKKO-LIFNR'      itab-vend_no,
        ''   'RM06E-BSART'     itab-ord_typ,
        ''   'RM06E-BEDAT'     itab-date,
        ''   'EKKO-EKORG'      itab-purch_org,
        ''   'EKKO-EKGRP'      itab-purch_grp,
        ''   'RM06E-WERKS'     itab-plant,
        ''   'RM06E-LGORT'     itab-sloc,
        ''   'RM06E-MATKL'     itab-mat_grp.
      PERFORM line_bdc_tab.
      v_lifnr = itab-vend_no.
      v_ekorg = itab-purch_org.
      v_werks = itab-plant.
     v_bednr = itab-bednr.
    ELSE.
      IF v_lifnr = itab-vend_no   AND
         v_ekorg = itab-purch_org AND
         v_werks = itab-plant.
       v_bednr = itab-bednr.
        v_tabix2 = v_tabix2 + 1.
        PERFORM line_bdc_tab.
      ELSE.
        PERFORM bdc_dynpro USING:
          'X'  'SAPMM06E'        '0100',
          ''   'BDC_OKCODE'      '/00',
          ''   'EKKO-LIFNR'      itab-vend_no,
          ''   'RM06E-BSART'     itab-ord_typ,
          ''   'RM06E-BEDAT'     itab-date,
          ''   'EKKO-EKORG'      itab-purch_org,
          ''   'EKKO-EKGRP'      itab-purch_grp,
          ''   'RM06E-WERKS'     itab-plant,
          ''   'RM06E-LGORT'     itab-sloc,
          ''   'RM06E-MATKL'     itab-mat_grp.
        CLEAR v_tabix2.
        v_tabix2 = v_tabix2 + 1.
        PERFORM line_bdc_tab.
        v_lifnr = itab-vend_no.
        v_ekorg = itab-purch_org.
        v_werks = itab-plant.
       v_bednr = itab-bednr.
      ENDIF.
    ENDIF.
    READ TABLE itab2 WITH KEY vend_no   = itab-vend_no
                              purch_org = itab-purch_org
                              plant     = itab-plant.
    IF v_tabix = 1.
      MOVE syst-tabix TO v_index.
    ENDIF.
    v_index = v_index + 1.
    READ TABLE itab2 INDEX v_index.
    IF itab2-vend_no   = itab-vend_no   AND
       itab2-purch_org = itab-purch_org AND
       itab2-plant     = itab-plant.
      IF l1 = v_tabix.
        PERFORM call_save.
        CALL TRANSACTION 'ME21' USING bdctab
        MODE 'A'
        UPDATE 'S'
        MESSAGES INTO messtab.
        CLEAR bdctab.
        REFRESH bdctab.
      ENDIF.
    ELSE.
      PERFORM call_save.
      CALL TRANSACTION 'ME21' USING bdctab
      MODE 'A'
      UPDATE 'S'
      MESSAGES INTO messtab.
      CLEAR bdctab.
      REFRESH bdctab.
    ENDIF.
  ENDLOOP.
ENDFORM.                    " create_bdcdata
*&      Form  bdc_dynpro
      text
     -->P_0120   text
     -->P_0121   text
     -->P_0122   text
FORM bdc_dynpro  USING    p1
                          p2
                          p3.
  IF p1 = 'X'.
    bdctab-dynbegin = p1.
    bdctab-program = p2.
    bdctab-dynpro = p3.
  ELSE.
    bdctab-fnam = p2.
    bdctab-fval = p3.
  ENDIF.
  APPEND bdctab.
  CLEAR bdctab.
ENDFORM.                    " bdc_dynpro
*&      Form  line_bdc_tab
      text
-->  p1        text
<--  p2        text
FORM line_bdc_tab .
  PERFORM bdc_dynpro USING:
    'X'  'SAPMM06E'        '0120',
    ''   'BDC_OKCODE'      '/00'.
  MOVE v_tabix2 TO c_tabix.
  CONCATENATE 'EKPO-EMATN(' c_tabix ')'  INTO v_mat_no.
  CONCATENATE 'EKPO-MENGE(' c_tabix ')'  INTO v_mat_quant.
  CONDENSE v_mat_no.
  CONDENSE v_mat_quant.
  PERFORM bdc_dynpro USING:
    '' v_mat_no    itab-mat_no,
    '' v_mat_quant itab-quant.
ENDFORM.                    " line_bdc_tab
*&      Form  call_save
      text
-->  p1        text
<--  p2        text
FORM call_save .
  PERFORM bdc_dynpro USING:
   'X'  'SAPMM06E'        '0120',
    ''   'BDC_OKCODE'      '=BU',
    'X'    'SAPLSPO1'        '0300',
    ''     'BDC_OKCODE'      '=YES'.
ENDFORM.                    " call_save

<b>Overview</b>
loop at itab.
call transaction ......
if sy-subrc <> '0'.
perform error_message.
endif.
endloop.
form error_message.
call funtion 'format_message'. * to write the error message in to the screen
endform.
See the below example code for BDMSGCOLL Structure ...
REPORT znit_bdc_assign
NO STANDARD PAGE HEADING LINE-SIZE 255.
for programs doing a data transfer by creating a batch-input session
and
for programs doing a data transfer by CALL TRANSACTION USING
*******Here SESSION = ' ' and CTU = 'X'
DATA: ctumode LIKE ctu_params-dismode VALUE 'N' ,
cupdate LIKE ctu_params-updmode VALUE 'L' ,
e_group(12), "group name of error-session
e_user(12) , "user for error-session
e_keep VALUE 'X', "'X' = keep session if finished
e_hdate LIKE sy-datum.
DATA: smalllog VALUE ' ' ,
nodata VALUE '/'.
DATA: flag .
DATA DECLARATION *
TYPES: begin of t_result,
matnr(18) , "TYPE RMMG1-MATNR
maktx(40) , "TYPE makt-maktx
bismt(18) , "TYPE mara-bismt
brgew(13) , "TYPE mara-brgew
gewei(3) , "TYPE mara-gewei
message(250), "Message
END OF t_result .
DATA : right TYPE STANDARD TABLE OF t_result ,
wrong TYPE STANDARD TABLE OF t_result ,
wa_result TYPE t_result .
data definition
Batchinputdata of single transaction
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
messages of call transaction
DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
error session opened (' ' or 'X')
DATA: e_group_opened.
message texts
TABLES: t100.
*INITIALIZATION
INITIALIZATION.
MOVE sy-uname TO e_user .
Start new transaction according to parameters *
FORM bdc_transaction USING tcode.
DATA: l_mstring(480).
DATA: l_subrc LIKE sy-subrc.
batch input session
REFRESH messtab.
CALL TRANSACTION tcode USING bdcdata
MODE ctumode
UPDATE cupdate
MESSAGES INTO messtab.
l_subrc = sy-subrc.
IF smalllog <> 'X'.
WRITE: / 'CALL_TRANSACTION', "CH01
tcode, "CH01
'returncode:'(i05), "CH01
l_subrc, "CH01
'RECORD:', "CH01
sy-index. "CH01
LOOP AT messtab.
SELECT SINGLE * FROM t100 WHERE sprsl = messtab-msgspra
AND arbgb = messtab-msgid
AND msgnr = messtab-msgnr.
IF sy-subrc = 0.
l_mstring = t100-text.
IF l_mstring CS '&1'.
REPLACE '&1' WITH messtab-msgv1 INTO l_mstring.
REPLACE '&2' WITH messtab-msgv2 INTO l_mstring.
REPLACE '&3' WITH messtab-msgv3 INTO l_mstring.
REPLACE '&4' WITH messtab-msgv4 INTO l_mstring.
ELSE.
REPLACE '&' WITH messtab-msgv1 INTO l_mstring.
REPLACE '&' WITH messtab-msgv2 INTO l_mstring.
REPLACE '&' WITH messtab-msgv3 INTO l_mstring.
REPLACE '&' WITH messtab-msgv4 INTO l_mstring.
ENDIF.
CONDENSE l_mstring.
WRITE: / messtab-msgtyp, l_mstring(250).
IF messtab-msgtyp = 'S' . "If successfully uploaded CH01
flag = '1' .
ELSE .
flag = '2' . "if not succesfully uploaded CH01
ENDIF.
MOVE l_mstring TO wa_result-message .
ELSE.
WRITE: / messtab.
ENDIF.
ENDLOOP.
SKIP.
Erzeugen fehlermappe ************************************************
IF l_subrc <> 0 AND e_group <> space.
IF e_group_opened = ' '.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
group = e_group
user = e_user
keep = e_keep
holddate = e_hdate.
e_group_opened = 'X'.
ENDIF.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = tcode
TABLES
dynprotab = bdcdata.
ENDIF.
ENDIF.
REFRESH bdcdata.
ENDFORM.
Start new screen *
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM.
Insert field *
FORM bdc_field USING fnam fval.
IF fval <> nodata.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDIF.
ENDFORM.
*Structure of the internal table in which data has to be uploaded
TYPES: BEGIN OF t_final,
matnr(18) , "TYPE RMMG1-MATNR
maktx(40) , "TYPE makt-maktx
bismt(18) , "TYPE mara-bismt
brgew(13) , "TYPE mara-brgew
gewei(3) , "TYPE mara-gewei
END OF t_final .
DATA: answer , "return value in popup_to_comfirm
count1 TYPE i , "no. of records not succusfully uploaded
count2 TYPE i . "no. of records successfully uploaded
DATA: i_final TYPE STANDARD TABLE OF t_final ,
wa_final TYPE t_final .
PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY.
stores file name to be uploaded
AT SELECTION SCREEN *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file .
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = ' '
DEF_PATH = ' '
mask = ',.,..'
MODE = ' '
TITLE = ' '
IMPORTING
filename = p_file
RC =
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
START OF SELECTION *
START-OF-SELECTION.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = 'Confirm Pop-UP'
DIAGNOSE_OBJECT = ' '
text_question = 'Would you like to proceed?'
text_button_1 = 'Yes'(001)
icon_button_1 = 'ICON_OKAY'
text_button_2 = 'No'(002)
icon_button_2 = 'ICON_CANCEL'
default_button = '1'
display_cancel_button = 'X'
USERDEFINED_F1_HELP = ' '
start_column = 25
start_row = 6
POPUP_TYPE =
IMPORTING
answer = answer
TABLES
PARAMETER =
EXCEPTIONS
text_not_found = 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.
CHECK answer EQ '1'.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
CODEPAGE = ' '
filename = p_file
filetype = 'DAT'
HEADLEN = ' '
LINE_EXIT = ' '
TRUNCLEN = ' '
USER_FORM = ' '
USER_PROG = ' '
DAT_D_FORMAT = ' '
IMPORTING
FILELENGTH =
TABLES
data_tab = i_final
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
OTHERS = 10
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT i_final INTO wa_final .
PERFORM bdc_dynpro USING 'SAPLMGMM' '0060'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RMMG1-MATNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RMMG1-MATNR'
wa_final-matnr.
MOVE wa_final-matnr TO wa_result-matnr .
PERFORM bdc_dynpro USING 'SAPLMGMM' '0070'.
PERFORM bdc_field USING 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_field USING 'MSICHTAUSW-KZSEL(01)'
'X'.
PERFORM bdc_dynpro USING 'SAPLMGMM' '4004'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
PERFORM bdc_field USING 'MAKT-MAKTX'
wa_final-maktx.
PERFORM bdc_field USING 'BDC_CURSOR'
'MARA-BISMT'.
PERFORM bdc_field USING 'MARA-BISMT'
wa_final-bismt.
PERFORM bdc_field USING 'MARA-BRGEW'
wa_final-brgew.
PERFORM bdc_field USING 'MARA-GEWEI'
wa_final-gewei.
MOVE wa_final-maktx TO wa_result-maktx .
MOVE wa_final-bismt TO wa_result-bismt .
MOVE wa_final-brgew TO wa_result-brgew .
MOVE wa_final-gewei TO wa_result-gewei .
PERFORM bdc_transaction USING 'MM02'.
flag = '1' Record updated successfully
flag = '2' Record not updated
IF flag = '1' .
APPEND wa_result TO right .
count1 = count1 + 1 .
ELSEIF flag = '2' .
APPEND wa_result TO wrong .
count2 = count2 + 1 .
ENDIF .
ENDLOOP.
Report Generation
WRITE : ' Success Item' .
SKIP .
WRITE : / ' Number of Success Items: ', count1 , ' Items.' .
SKIP .
WRITE: / 'Material Number ',
19 'Material Name',
59 'Old Mat. Name',
77 'Gross Wt.',
90 'Weight Unit',
105 'Message' .
WRITE: sy-uline .
LOOP AT right INTO wa_result .
WRITE: / wa_result-matnr ,
19 wa_result-maktx ,
59 wa_result-bismt ,
77 wa_result-brgew ,
90 wa_result-gewei ,
105 wa_result-message .
ENDLOOP .
SKIP 2 .
WRITE : /' Error Item' .
SKIP .
WRITE : / ' Number of Error Items: ', count2 , ' Items.' .
SKIP .
WRITE: / 'Material Number ',
19 'Material Name',
59 'Old Mat. Name',
77 'Gross Wt.',
90 'Weight Unit',
105 'Message' .
WRITE: sy-uline .
LOOP AT wrong INTO wa_result .
WRITE: / wa_result-matnr ,
19 wa_result-maktx ,
59 wa_result-bismt ,
77 wa_result-brgew ,
90 wa_result-gewei ,
105 wa_result-message .
ENDLOOP .
Reward Points if it is helpful
Rgds,
Naren
Message was edited by:
        Naren Someneni

Similar Messages

  • BDC for Purchase order text updation in MM02 Transaction

    Hi ALL,
    I am updating purchase order text of a material in MM02 using BDC program.
    I have done recording, and the program is updating text if the text field already contains some value. but,
    when the field is empty and if the program tries to feed new data then it is not working.
    Please help me!
    regds,
    Rajan

    Hi
    material master purchase order long text
    you can use through BDC or LSMW it is possible,
    here we need to check in lsmw  Direct input mentod Program name "/SAPDMC/SAP_LSMW_IMPORT_TEXTS"  object name (0001) method(0001) program type (D).
    Header we have ---  MATNR and TEXT ID
    Item ---LINE(Text line).
    in header- for NAME and ID map the source fields MATNR and TEXID respectively.
    OBJECT and SPRAS pass the constants.
    in Item--for TEXTFORMAT pass the constant '*' and for the TEXTLINE map the input field LINE of the ITEM structure.
        or else u can check in SE37 'CREATE_TEXT'   , in that function module check it object Id , name , spras, lineitem,  language "E"
    here i mention example of text flat file,
    H  100-100 best
    longtext1

  • PO 'No goods receipt possible for purchase order'

    Hi gurus!
    While trying to make Confirmation of a PO in the SRM Portal the user is getting the error 'No goods receipt possible for purchase order'
    The scenario used is Classic, so PO is replicated directly to the R/3 system.
    Any idea why this is happening?
    Thanks a lot!

    Hi, thanks for the quick reply!
    Where i can check the Item category?
    I found a field called 'subitem category' but it's blank
    with this possible values:
    1 Variant                               
    2 Discount in kind: inclusive bonus qty.
    3 Empties                               
    4 Discount in kind: exclusive bonus qty.
    5 Prepack item                          
    6 Display item                          
    7 Set item                              
    8 Interchangeable items (IBU: A&D)      
    9 Pre-packing (SLS items)               
    H GT Bill of Material, Header Relevant  
    I GT Bill of Material, Item Relevant    
    About PO type i think it's EC (doc_type?), in R/3 is shown as EBP PO
    I checked in backend system, in the item details > Delivery and the 'Goods Receipt' is checked.

  • Goods-Receipt Block for Purchase Order depending on Goods-Receipt Date

    Hi,
    I want to set up the system so it can block the Goods-Receipt for Purchase Order respectively Scheduling Agreement if the Goods Receipt is about to take place 30 days or more before the Desired Delivery Date.
    For Example: If I have a Purchase Order with the desired delivery date 30.09.2008. I want to set up the system so, that it bans (forbids) the Goods Receipt before the 01.09.2008.
    If possible I would want to do that without additional programming. Is it possible to set up the system using only customising settings?
    Thanks for your help
    Bogdan

    Hello Marius-Bodgan,
    as this question is marked answered I assume you have received an solution for your requirement. Could you please share the solution with me by posting it here? I have the same requirement and did not find any possibility to do this in customizing.
    Thanks in advance,
    Emanuel
    Found the solution in thread Re: Goods Receipt
    Edited by: Emanuel Penalver on Jul 15, 2008 11:48 AM

  • Table for purchase order status

    Hello friends,
    There's a tab STATUS in purchase order (tcoe ME21N).
    I can't find a table which contains theses statuses.
    Anybody knows what's the table for purchase orders status ??
    Regards,
    Bahia

    Hi
    PO status is stored in Structure not in the table.
    Please use the List displays to get the information like ME2N,ME2L, ME2M, ME2K etc
    You can also get the information from the table EKKO, EKPO, EKET,EKBE
    Hope it helps
    thanks/karthik

  • Missing Parts report for Purchase Orders

    Hey Gurus,
    We are running the availability check for Purchase orders and the user group is wondering if there is a standard Missing Parts report in SAP similiar to transaction CO24 for Purchase Orders so that they can view all of the Purchase orders with missing parts.
    As a side note,  we are using subcontracting purchase orders.

    didn't get a response.

  • Require Standard DataSources for Purchase Orders

    Hi,
    Please provide me the standard datasources for purchase orders to get the data updated automatically in a BI System.
    I have to display report containing the purchase orders details of each day.
    Regards
    Sunil Kumar

    Hi,
    Following link will give you complete details of purchase order deports and data sources.
    http://help.sap.com/saphelp_nw70/helpdata/en/df/cfb839f6a7a307e10000000a11402f/frameset.htm
    Regards,
    Vishnu

  • Open items for purchase order its very urgent

    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

    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

  • Use of SAVE_TEXT in customer exits / BADI for purchase order

    Hi All,
    I am trying to save some long text by using SAVE_TEXT function module in a badi implementation for purchase order header text. The same is working fine if i try to update the PO header text via a report. But if i try using badi (the code is written in a PAI event for the BADI), then though the text transfer and save is successful during the code excution, but for the first time when i add any text its not visible in ME22N tcode. Since its an online event. But when i double click on that editor and the sap script editor gets opened. then i press back button, the text is appearing on the same small screen edtor . after this any number of time i edit or delete text, the save_text function module works fine.
    My issue is why for the first time always i have to double click on the editor to open the sap script editor. I have also included commit_text in this case after save_text FM.
    the requirement here goes like this. in one tab for PO header the user will enter some number (This is a customizing screen implemented through badi.) and the corresponsing discription should appear when user clicks on text tab in po header screen (me21n / me22n).
    Kindly help.
    Thanks
    Mamata

    Hi  mamata rath
    I have solve the problem which similar to yours.  the code which is as the following
    DATA: textline TYPE tdline,
            name TYPE c LENGTH 70,
            glines TYPE TABLE OF tline,
            gline  LIKE LINE OF glines,
            ls_header TYPE thead.
         CONCATENATE ch_eban-banfn ch_eban-bnfpo INTO name.
             ls_header-tdobject = 'EBAN'.
             ls_header-tdname = name.
             ls_header-tdid = 'B01'.
             ls_header-tdspras = sy-langu.
             CALL FUNCTION 'SAVE_TEXT'
               EXPORTING
    *           CLIENT                = SY-MANDT
                 header                = ls_header
    *           INSERT                = ' '
    *           SAVEMODE_DIRECT       = ' '
    *           OWNER_SPECIFIED       = ' '
    *           LOCAL_CAT             = ' '
    *         IMPORTING
    *           FUNCTION              =
    *           NEWHEADER             =
               tables
                 lines                 = glines
               EXCEPTIONS
                 ID                    = 1
                 LANGUAGE              = 2
                 NAME                  = 3
                 OBJECT                = 4
                 OTHERS                = 5
              IF sy-subrc = 0.
                  CALL FUNCTION 'COMMIT_TEXT'
                    EXPORTING
                      OBJECT                = 'EBAN'
                      NAME                  = name
    *                ID                    = '*'
    *                LANGUAGE              = '*'
    *                SAVEMODE_DIRECT       = ' '
    *                KEEP                  = ' '
    *                LOCAL_CAT             = ' '
    *              IMPORTING
    *                COMMIT_COUNT          =
    *              TABLES
    *                T_OBJECT              =
    *                T_NAME                =
    *                T_ID                  =
    *                T_LANGUAGE            =
              ENDIF.

  • Driver program for Purchase Order form "/SMB40/MMPO_A"

    Hi All
    Could you please suggest me Driver program for Purchase Order form "/SMB40/MMPO_A" ?
    Driver program "/SMB40/FM06P" does not have the same interface structure as this form, hence can not be used.
    << Text removed>>.
    Regards
    Ansh
    Edited by: Matt on Mar 27, 2009 7:22 AM - Please do not offer points

    Hi Ansh
    see this link
    [Driver program |https://forums.sdn.sap.com/click.jspa?searchID=24089230&messageID=6810108]
    Regards
    HAreesh Menon

  • Problem in creating a SyncBo for Purchase Order BAPIs

    Hello Everybody,
    I am trying to create a smart sync application for Purchase Orders.
    I have used standard bapis like BAPI_PO_GETDETAIL AND BAPI_PO_CREATE1.
    I have developed my own wrapper functions using these std bapis. For the PO creation i only plan to insert the necessary and mandatory data. The problem i face is that some of the tables in the create bapi which are mandatory for a PO creation are freezed in the SyncBo.
    Tables like POITEMX, POADDRDELIVERY, POSCHEDULE and structure POHEADERX are all required for the creation of a PO. Without this minimum data a PO cannot be created.
    After i have created the syncBo, on the mapping screen i can only see these tables under the create BAPI. But i am not able to perform the mapping of their fields. These are non-editable or i must say that they are freezed.
    And if i cannot map them then i cannot pass data for them from the client. Although i can do the mapping for the table PO_ITEM and the structure PO_HEADER.
    I hope i am able to expplain my problem. Kindly get back to me if i am not clear. Any sort of help is welcome.
    Thanking in advance,
    Saurabh.

    Hi Saurabh,
    Hope you are aware of the prerequisites for creating the BAPI Wrappers.
    If you want to insert some data into the Business Object, then you have to include
    GETLIST, GETDETAIL and CREATE Bapi Wrappers.
    I think in your case,
    You might not have mapped those fields in your GETLIST Bapi Wrapper.Just check whether you have mapped those fields that are necessary for PO creation in your GETLIST and GETDETAIL BApi wrapper mapping screen.
    Those fields you have mapped in the GETLIST and GETDETAIL BAPI wrappers will be visible (for selection - checkboxes will be editable) in the mapping screen for CREATE BAPI Wrapper.
    So first of all, you have to map fields there in the mapping screens for GETLIST and GETDETAIL Bapi Wrappers...
    check this thing...
    refer these links..
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/com.sap.km.cm.docs/library/mobile/mobile%20infrastructure/mobile%20development%20kit%202.5/content/appdev/smartsync/introduction.html
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/com.sap.km.cm.docs/library/mobile/mobile%20infrastructure/mobile%20development%20kit%202.5/content/appdev/smartsync/bapi_wrapper_types.html
    In the second link, you can see one figure, which is explaining the things that are to be satisfied by the BAPI Wrappers for SyncBO creation...
    Let me know If you have doubts in the prerequisite section itself...
    Regards,
    Kishor Gopinathan

  • Error:-document is in transfer for purchase order..creation is not possible

    Hello,
    While doing confirmation of PO I am getting this error, saying "document is in transfer for purchase order..creation is not possible".
    can anyone please suggest me solution on this type of error?

    Hi,
    Is the PO in ORDERED status? Is there any confirmation posted for this PO which might be stuck (idoc failed to reach back end)?
    If it is a case of idoc failure, then reprocess the idoc and then do the next confirmation.
    regards,
    MRao

  • Call BAPI_GOODSMVT_CREATE to create a goods receipt for purchase order

    Hi,
    I'm calling the bapi BAPI_GOODSMVT_CREATE to create a goods receipt for purchase order, but the following code doesn't work. It doesn't give me any kind of error message but it does nothing as well...
    Can anyone help me please?
    Thank You
    Hugo
    Code
    DATA: wa_goodsmvt_header  LIKE bapi2017_gm_head_01,
                            wa_goodsmvt_code    LIKE bapi2017_gm_code,
                            wa_bapi2017_gm_head TYPE bapi2017_gm_head_ret-mat_doc.
                      DATA: it_goodsmvt_item LIKE bapi2017_gm_item_create OCCURS  0 WITH HEADER LINE,
                            it_return        LIKE bapiret2 OCCURS  0 WITH HEADER LINE.
                      wa_goodsmvt_header-pstng_date = SY-DATUM.
                      wa_goodsmvt_header-doc_date   = SY-DATUM.
                      wa_goodsmvt_header-ref_doc_no = '4500000020'.
                      wa_goodsmvt_code-gm_code = '01'.          "Goods receipt for purchase Order
                      it_goodsmvt_item-stge_loc  = 'BPF2'.
                      it_goodsmvt_item-move_type = '101' .
                      it_goodsmvt_item-entry_qnt = 17.
                      it_goodsmvt_item-entry_uom = 'KG'.
                      it_goodsmvt_item-mvt_ind   = 'B'.
                      it_goodsmvt_item-po_number = '4500000020'.
                      it_goodsmvt_item-po_item   = '00010'.
                      it_goodsmvt_item-material  = '50'.
                      APPEND it_goodsmvt_item.
                      CALL FUNCTION  'BAPI_GOODSMVT_CREATE'
                        EXPORTING
                          goodsmvt_header  = wa_goodsmvt_header
                          goodsmvt_code    = wa_goodsmvt_code
                        IMPORTING
                          materialdocument = wa_bapi2017_gm_head
                        TABLES
                          goodsmvt_item    = it_goodsmvt_item
                          return            = it_return.
                        data: begin of errmsg occurs 10.
                                include structure bapiret2.
                        data: end of errmsg.
                        data: wmenge like iseg-menge,
                              errflag.
                        clear errflag.
                        loop at errmsg.
                          if errmsg-type eq 'E'.
                            write:/'Error in function', errmsg-message.
                            errflag = 'X'.
                          else.
                            write:/ errmsg-message.
                          endif.
                        endloop.
                        if errflag is initial.
                          commit work and wait.
                          if sy-subrc ne 0.
                            write:/ 'Error in updating'.
                            exit.
                          else.
                            write:/ 'Ok'.
                          endif.
                        endif.
                        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
                        EXPORTING
                        wait = ' '.

    Hi,
    Thank you for the asnwer! I'm a rookie at ABAP so please forgive my stupid questions
    I've changed the code to:
    DATA: wa_goodsmvt_header  LIKE bapi2017_gm_head_01,
                            wa_goodsmvt_code    LIKE bapi2017_gm_code,
                            wa_bapi2017_gm_head TYPE bapi2017_gm_head_ret-mat_doc.
                      DATA: it_goodsmvt_item LIKE bapi2017_gm_item_create OCCURS  0 WITH HEADER LINE,
                            it_return        LIKE bapiret2 OCCURS  0 WITH HEADER LINE.
                      wa_goodsmvt_header-pstng_date = SY-DATUM.
                      wa_goodsmvt_header-doc_date   = SY-DATUM.
                      wa_goodsmvt_header-ref_doc_no = '4500000020'.
                      wa_goodsmvt_code-gm_code = '01'.          "Goods receipt for purchase Order
                      it_goodsmvt_item-plant     = 'BP01'.
                      it_goodsmvt_item-stge_loc  = 'BPF2'.
                      it_goodsmvt_item-move_type = '101' .
                      it_goodsmvt_item-entry_qnt = 10.
                      it_goodsmvt_item-entry_uom = 'KG'.
                      it_goodsmvt_item-mvt_ind   = 'B'.
                      it_goodsmvt_item-po_number = '4500000020'.
                      it_goodsmvt_item-po_item   = '10'.
                      it_goodsmvt_item-material  = '50'.
                      APPEND it_goodsmvt_item.
                      CALL FUNCTION  'BAPI_GOODSMVT_CREATE'
                        EXPORTING
                          goodsmvt_header  = wa_goodsmvt_header
                          goodsmvt_code    = wa_goodsmvt_code
                        IMPORTING
                          materialdocument = wa_bapi2017_gm_head
                        TABLES
                          goodsmvt_item    = it_goodsmvt_item
                          return            = it_return.
                          write:/ it_return-message.
    And the return message is : Material document data and PO data do not match (Material)
    Any idea of what might be the problem?
    Thanks

  • No goods receipt possible for purchase order

    Hi Experts,
       Received the goods 10 PC from Vendor on one date, then reversing the GRN on another date, So now GRN total quantity is zero. I am getting error  u201CERROR - 036No goods receipt possible for purchase order 43086066 00220 " while again i am trying to do GRN. Please help me to solve the problem.
    Thanks

    Hi,
    Try to do the GR wrt Mat doc # which you have cancelled.
    regds,
    CB

  • No goods receipt possible for purchase order 'PO#" "Lineitem"

    Hi gurus,
    Please help on below error.
    While doing return to vendor transaction using BAPI 'BAPI_GOODSMVT_CREATE' error 'No goods receipt possible for purchase order 'PO#" "Lineitem"' was encountered. As checked, all data are correct including the plant, sloc, PO#, stocks, batch.
    Please kindly advice on how to resolve the issue.
    Thank you in advance.

    Hi,
    Few things which immediately comes to my mind.
    1. Check if the PO is released?
    2. Check if the confirmation control is properly set in Confirmations tab of item details of a PO.
    3. Check if the Goods Receipt indicator is ticked at item level of PO.
    I hope these helps.
    Kind Regards,
    Prakash

Maybe you are looking for