Shared Top Border

Enterprise Resource
Planning Portal

 

Advertise | Founder BLOG

ERPGenie.COM ABAP Tips and Tricks Database

THE ultimate
ERP website

 

Forums | Vote for us |

Google    Other Search Options

Home arrow Sample Code arrow ABAP Reports arrow Download components of Production Order
Download components of Production Order PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Anon.   
Wednesday, 09 May 2007
This program downloads the components of Production Order to your local harddisk.
REPORT ZDOWNCOMP No standard page heading message-id zz.

tables: caufv,mseg,mara,stpo,aufk,marc,mast,VBAk,makt.

select-options: aufnr1 for aufk-aufnr.
PARAMETERS: p_file LIKE rlgrap-filename obligatory.

Data: begin of itab occurs 10,
      aufnr like caufv-aufnr,     "order number
      AUART like caufv-auart,     "order type
      werks like caufv-werks,     "plant
      STLBEZ like caufv-STLBEZ,   "material number
      maktx like MAKT-MAKTX,      "material description
      stlnr like caufv-stlnr,     "BOM number
      ap_num(10) type c,          "
      GAMNG like caufv-GAMNG,      "Order quantity
      GMEIN like caufv-gmein,      "UOM
      RSNUM like caufv-rsnum,
      end of itab.

Data: begin of itab1 occurs 10,
      aufnr like caufv-aufnr,    "order number
      AUART like caufv-auart,    "order type
      werks like caufv-werks,    "plant
      STLBEZ like caufv-STLBEZ,  "material number
      maktx like MAKT-MAKTX,     "material description
      ap_num(10) type c,         "
      GAMNG like caufv-gamng,    "Order quantity
      GMEIN like caufv-gmein,    "UOM
      POSNR like stpo-posnr,     "item
      matnr like stpo-idnrk,     "Component
      BDMNG like stpo-menge,     "planned quantity
      meins like stpo-meins,     "UOM
      recv_loc like stpo-lgort,  "receiving location
      lgort like stpo-lgort, "issuing location
      end of itab1.

data: H_MASK(20) TYPE  C VALUE   ',*.txt ,*.txt.     '.

**********************check for file validity****************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  "uploading file from PC
  CALL FUNCTION 'WS_FILENAME_GET'
       EXPORTING
            DEF_FILENAME     = ' '
            mask             = H_mask
       IMPORTING
            FILENAME         = p_file
       EXCEPTIONS
            INV_WINSYS       = 1
            NO_BATCH         = 2
            SELECTION_CANCEL = 3
            SELECTION_ERROR  = 4
            OTHERS           = 5.
  if sy-subrc <> 0.
    message i001 with 'Error opening PC file!'.
  endif.

*******************************************************
start-of-selection.

  refresh:itab,itab1.
  clear:itab,itab1.


  select aufnr auart werks STLBEZ stlnr GAMNG gmein RSNUM appending
     corresponding fields of table itab from caufv
     where aufnr in aufnr1.

  loop at itab.
    select single maktx into itab-maktx from makt
       where matnr = itab-STLBEZ.
    modify itab.
  endloop.

  loop at itab.
    select posnr matnr BDMNG meins lgort appending corresponding fields
       of table itab1 from resb where werks = itab-werks
       and aufnr = itab-aufnr and RSNUM = itab-RSNUM and dumps = ''.
    if sy-subrc = 0.
      loop at itab1 where aufnr = ''.
          move-corresponding itab to itab1.
          modify itab1.
      endloop.
      delete itab.
    endif.
  endloop.

  read table itab1.
  if sy-subrc <> 0.
    message I001 with 'No valid data!'.
  else.
    CALL FUNCTION 'WS_DOWNLOAD' "Use GUI_DOWNLOAD in later SAP versions
         EXPORTING
              FILENAME            = P_FILE
              FILETYPE            = 'DAT'
         TABLES
              DATA_TAB            = itab1
         EXCEPTIONS
              FILE_OPEN_ERROR     = 1
              FILE_WRITE_ERROR    = 2
              INVALID_FILESIZE    = 3
              INVALID_TABLE_WIDTH = 4
              INVALID_TYPE        = 5
              NO_BATCH            = 6
              UNKNOWN_ERROR       = 7
              OTHERS              = 8.
    if sy-subrc = 0.
      message i001 with 'File downloaded'.
    else.
      message i001 with 'Error opening PC file!'.
    endif.
  endif.

*---End of Program

Related Items:

 
< Prev   Next >

Google Search

Google Ads

Shared Bottom Border

Contact Us | Polls | Add URL | Contribute | Privacy | Terms | Feedback

Discussion Forum | BLOG | Consultants: Post your resume | Companies: Advertise on ERPGenie.COM | Post Job
Financials Consultant | Consultant Review | Gallia Consulting | Supply Chain Project | SAP Financials Forum
GenieHoldings.COM, Inc. | Genie Press | WorkflowGenie | ESAGenie | ERPTopSites | ABAP Tips and Tricks | SAP Solutions Database

EDIGenie | Searching Survivor