SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Create Sales Order with the VA01 batch input



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Sep 29, 2007 3:27 pm    Post subject: Create Sales Order with the VA01 batch input Reply with quote

Code:

REPORT zxyz.

data: bdctab like bdcdata occurs 0 with header line.

data: messtab like bdcmsgcoll occurs 0 with header line.


DATA: BEGIN OF itab OCCURS 0,
  ord_typ(2),
  sales_org(4),
  dist_chan(2),
  div(2),
  PO_No(10),
  SP(6),
  SH(6),
  pay_term(4),
  inc_term(3),
  inc_inf(10),
  material(4),
  item(2),
  ord_quan(5),
  plant(4),
  amount(7),
  Netweight(5),
  Grossweight(5),
END OF itab.


start-of-selection.
  perform get_data.
  perform create_bdcdata.

**&---------------------------------------------------------------------
*
**& Form get_data
**&---------------------------------------------------------------------
*
** text
**----------------------------------------------------------------------
*
** --> p1 text
** <-- p2 text
**----------------------------------------------------------------------
*
FORM get_data .

  CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
      FILENAME = 'C:\Documents and Settings\Ekansh\Desktop\salesorder'
      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.
 
ENDFORM. " get_data

***&--------------------------------------------------------------------
*-*
***& Form bdcdata
***&--------------------------------------------------------------------
*-*
*** text
***---------------------------------------------------------------------
*-*
*** --> p1 text
*** <-- p2 text
***---------------------------------------------------------------------
*-*
FORM create_bdcdata .
 
    LOOP AT itab.
      PERFORM bdc_dynpro USING:
     
      'X' 'SAPMV45A' '0101',
    '' 'BDC_OKCODE' '/00',
    '' 'VBAK-AUART' itab-ord_typ,
    '' 'VBAK-VKORG' itab-sales_org,
    '' 'VBAK-VTWEG' itab-dist_chan,
    '' 'VBAK-SPART' itab-div,
   
    'X' 'SAPMV45A' '4001',
    '' 'BDC_OKCODE' '=T\02',
    '' 'VBKD-BSTKD' itab-PO_No,
    '' 'KUAGV-KUNNR' itab-SP,
    '' 'KUWEV-KUNNR' itab-SH,
    '' 'VBKD-ZTERM' itab-pay_term,
    '' 'VBKD-INCO1' itab-inc_term,
    '' 'VBKD-INCO2' itab-inc_inf,
    '' 'RV45A-MABNR(01)' itab-material,
    '' 'VBAP-POSNR(01)' itab-item,
    '' 'RV45A-KWMENG(01)' itab-ord_quan,
    '' 'VBAP-WERKS(01)' itab-plant,
    '' 'KOMV-KBETR(01)' itab-amount,
   
    'X' 'SAPMV45A' '4001',
    '' 'BDC_OKCODE' '/00',
    '' 'VBAP-NTGEW(01)' itab-Netweight,
    '' 'VBAP-BRGEW(01)' itab-Grossweight,
   
    'X' 'SAPMV45A' '4001',
    '' 'BDC_OKCODE' '=SICH'.
   
    call transaction 'va01' using bdctab
      MODE 'A'
      update 'S'
      messages into messtab.
    REFRESH bdctab.
  ENDLOOP.

ENDFORM. " create_bdcdata

*&---------------------------------------------------------------------*
*& Form bdc_dynpro
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0125 text
* -->P_0126 text
* -->P_0127 text
*----------------------------------------------------------------------*
FORM bdc_dynpro USING P1 P2 P3.

  IF P1 = 'X'.
    CLEAR BDCTAB.
    BDCTAB-DYNBEGIN = P1.
    BDCTAB-PROGRAM = P2.
    BDCTAB-DYNPRO = P3.
  ELSE.
    CLEAR BDCTAB.
    BDCTAB-FNAM = P1.
    BDCTAB-FVAL = P2.
  ENDIF.
  APPEND BDCTAB.

ENDFORM. " bdc_dynpro
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.