Sales Order Creation Using Web Dynpro ABAP

Share Embed Donate


Short Description

Sales Order Creation in Webdynpro...

Description

Sales Sales Order Creation usin g ABAP WebDynpro

Sales Order Creation using Web Dynpro ABAP

 Appl  Ap pl ies to : SAP NetWeaver 2004s, Web Dynpro ABAP

Summary This step by step exercise helps to create a sales order application using Web Dynpro ABAP.  Au th or : Kathirvel Balakrishnan Company: Wipro Technologies Created on:  07 February 2007

 Auth  Au thor or Bi Bio o Kathirvel Balakrishnan is working as a ABAP Consultant for Wipro Technologies. His areas of interests are ABAP ( Object, WebDynpro), WebD ynpro), Java, VBA and PHP Programming.

SAP DEVELOPER NETWORK | sdn.sap.com

© 2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

1

Sales Order Creation usin g ABAP WebDynpro

Table of Contents

 Applies to: ........................................................................................................................................ 1 Summary.......................................................................................................................................... 1  Author Bio ........................................................................................................................................ 1 Prerequisite...................................................................................................................................... 3 Sample Screen Shots ...................................................................................................................... 3 Step 1 – Create a Web Dynpro Component .................................................................................... 4 Step 2 – Create nodes in the Component Controller ...................................................................... 4 Step 3 – Create a methods to create sales order............................................................................ 5 Step 4 – Creating Views .................................................................................................................. 8 Step 5 - Assigning Views to Window ............................................................................................... 9 Step 6 – Create WebDynpro Application....................................................................................... 10 Related Content............................................................................................................................. 11 Disclaimer and Liability Notice....................................................................................................... 12

SAP DEVELOPER NETWORK | sdn.sap.com

© 2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY  | bpx.sap.com

2

Sales Order Creation usin g ABAP WebDynpro

Prerequisite This example requires basic knowledge about ABAP.

Sampl e Screen Shots The Web Dynpro ABAP Sales Order creation application,

Sales Order created in SAP R/3 System,

SAP DEVELOPER NETWORK | sdn.sap.com

© 2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY  | bpx.sap.com

3

Sales Order Creation usin g ABAP WebDynpro

Step 1 – Create a Web Dynpro Compon ent Create a WebDynpro component with the windows name SO_CREATE.

Step 2 – Create nodes in the Component Controller Now double click the Component Controller and navigate to the Context Tab. Create four Nodes under that as shown below. In this demo application only a few parameters of the BAPI_SALESORDER_CREATEFROMDAT2 has been used. Incase real time scenarios one might require to use all the parameters. Hence there would be a need to create additional nodes in the Component Controller.

SAP DEVELOPER NETWORK | sdn.sap.com

© 2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY  | bpx.sap.com

4

Sales Order Creation usin g ABAP WebDynpro

Step 3 – Create a methods to create sales order

The source code for the method is given below, METHOD  creat e_sal es_or der . * Declaration for Order Header Node

DATA: node_or der _header  TYPE REF  TO i f _wd_cont ext _node, el em_or der _header  TYPE REF  TO i f _wd_cont ext _el ement , st r u_or der_ header  TYPE  i f _component cont r ol l er =>el ement _or der _header . * Declaration for Order Items Node

DATA: node_or der_ i t ems  TYPE REF  TO i f _wd_cont ext _node, el em_or der _i t ems  TYPE REF  TO i f _wd_cont ext _el ement , st r u_order _i t ems  TYPE i f _component cont r ol l er =>el ement _or der _i t ems . * Declaration for Order Partners Node

DATA: node_or der_ par t ner s  TYPE REF  TO i f _wd_cont ext _node, SAP DEVELOPER NETWORK | sdn.sap.com

© 2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY  | bpx.sap.com

5

Sales Order Creation usin g ABAP WebDynpro

el em_or der_ par t ner s  TYPE REF  TO i f _wd_cont ext _el ement , stru_order_partners  TYPE i f _component cont r ol l er =>el ement _or der _par t ner s . * Declaration for Order Conditions Node

DATA: node_order _condi t i ons  TYPE REF  TO i f _wd_cont ext _node, el em_or der_ condi t i ons  TYPE REF  TO i f _wd_cont ext _el ement , st r u_or der _condi t i ons  TYPE i f _component cont r ol l er =>el ement _or der _condi t i ons . * Read Context Details * via lead selection

node_or der _header = wd_cont ext - >get _c hi l d_node( name = i f _c omponent cont r ol l er =>wdct x_or der _ header ) . el em_or der _header = node_ or der _header - >get _el ement ( ) . el em_or der _header - >get _st at i c_at t r i but es( I MPORTI NG st at i c_at t r i but es = st r u_order _header ) . * via lead selection

node_or der _i t ems = wd_cont ext - >get _chi l d_node( name = i f _c omponent cont r ol l er =>wdct x_or der _ i t ems ) . el em_or der _i t ems = node_or der _i t ems- >get _el ement ( ) . el em_order _i t ems- >get _st at i c_at t r i but es( I MPORTI NG st at i c_at t r i but es = st r u_or der _i t ems ) . * via lead selection

node_or der _par t ner s = wd_cont ext - >get _chi l d_node( name = i f _component cont r ol l er =>wdct x_or der _par t ner s ) . el em_or der _par t ner s = node_or der _par t ner s- >get _el ement ( ) . el em_or der _par t ner s- >get _st at i c_at t r i but es( I MPORTI NG st at i c_at t r i but es = st r u_or der _par t ner s ) . * via lead selection

node_or der _condi t i ons = wd_cont ext - >get _chi l d_node( name = i f _component cont r ol l er =>wdct x_or der _condi t i ons ) . el em_or der _condi t i ons = node_or der _condi t i ons- >get _el ement ( ) . el em_order _condi t i ons- >get _st at i c_at t r i but es( I MPORTI NG st at i c_at t r i but es = st r u_or der _condi t i ons ). DATA: v_sal es_doc  TYPE bapi vbel n- vbel n. DATA: w_or der _header _i n  TYPE  bapi sdhd1, i _or der _par t ner s  TYPE  TABLE OF  bapi w_or der _par t ners  TYPE  bapi par nr , i _ r e t ur n  TYPE  TABLE OF  bapi w_r et ur n  TYPE  bapi r et 2, i _or der _i t ems_i n  TYPE  TABLE OF  bapi w_or der _i t ems_i n  TYPE  bapi sdi t m, i _or der _condi t i ons_i n  TYPE  TABLE OF  bapi w_or der _condi t i ons_i n  TYPE  bapi cond.

par nr , r et 2, sdi t m, cond,

* Order Header Details

CLEAR  w_or der _header _i n. SAP DEVELOPER NETWORK | sdn.sap.com

© 2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY  | bpx.sap.com

6

Sales Order Creation usin g ABAP WebDynpro

w_or der_ header _i w_order _header _i w_order _header _i w_or der _header _i w_or der_ header _i w_order _header _i

n- doc_t ype n- sal es_or g n- di st r _chan n- di vi si on n- r eq_dat e_h n- sal es_di st

= = = = = =

st r u_or der _header - doc_t ype. st r u_order _header - sal es_or g. st r u_order _header - di st r _chan. st r u_or der _header - di vi si on. st r u_or der _header - r eq_dat e_h. st r u_order _header - sal es_di st .

* Order Item Details

CLEAR: i _order _i t ems_i n, w_or der _i t ems_i n. w_order _i t ems_i n- mat er i al = st r u_or der _i t ems- mat er i al . w_or der_ i t ems_i n- sal qt ynum = st r u_or der _i t ems- sal qt ynum. CALL FUNCTI ON ' CONVERSI ON_EXI T_ALPHA_I NPUT' EXPORTI NG i nput = w_or der _i t ems_i n- mat eri al I MPORTI NG out put   = w_or der _i t ems_i n- mat er i al . APPEND  w_or der _i t ems_i n  TO  i _or der _i t ems_i n. * Order Partner Details

CLEAR: i _order _par t ner s, w_or der _par t ner s. w_or der _par t ner s- par t n_r ol e = st r u_or der _par t ner s- par t n_r ol e. w_or der _par t ner s- par t n_numb = st r u_or der _par t ner s- par t n_numb. CALL FUNCTI ON ' CONVERSI ON_EXI T_ALPHA_I NPUT' EXPORTI NG i nput = w_ or der _par t ner s- par t n_numb I MPORTI NG out put = w_or der _par t ner s- par t n_numb. APPEND  w_or der _par t ner s  TO  i _or der _par t ner s. * Order Condition Details

CLEAR: i _or der _condi w_or der_ condi t i ons_i w_order _condi t i ons_i w_order _condi t i ons_i APPEND  w_or der _condi

t i ons_i n, w_or der _condi t i ons_i n. n- i t m_number = st r u_or der_ condi t i ons- i t m_number . n- cond_t ype = st r u_order _condi t i ons- cond_t ype. n- cond_val ue = st r u_order _condi t i ons- cond_val ue. t i ons_i n  TO i _ or der _ condi t i ons _ i n.

* Create Sales Order BAPI Call

CALL FUNCTI ON ' BAPI _SALESORDER_CREATEFROMDAT2' EXPORTI NG or der _header _i n = w_or der _header _i n I MPORTI NG sal esdocument = v_s al es_ doc  TABLES return = i _r et ur n or der _i t ems_i n = i _or der _i t ems_i n or der _par t ner s = i _or der _par t ner s or der _condi t i ons_i n = i _or der _condi t i ons_i n. * Get message manager 

DATA: l _ cur r ent _ cont r o l l er  TYPE REF  TO i f _ wd_ cont r ol l er , l _message_manager  TYPE REF  TO i f _wd_message_manager . l _cur r ent _cont r ol l er ?= wd_t hi s- >wd_get _api ( ) . CALL METHOD l _cur r ent _cont r ol l er - >get _message_manager RECEI VI NG message_manager = l _message_manager . SAP DEVELOPER NETWORK | sdn.sap.com

© 2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY  | bpx.sap.com

7

Sales Order Creation usin g ABAP WebDynpro

DATA: v_message_t ext  TYPE st r i ng. * When Sales Order is created commit the data

I F NOT  v_sal es_doc I S I NI TI AL. CALL FUNCTI ON ' BAPI _TRANSACTI ON_ COMMI T' EXPORTI NG wai t = ' X' . CONCATENATE ' Sal es Document '   v_sal es_doc ' has been creat ed. ' I NTO  v_message_t ext SEPARATED BY  space. * Report Success message

CALL METHOD l _message_manager - >r epor t _s uccess EXPORTI NG message_t ext = v_message_t ext . ELSE. v_mess age_t ext = ' Er r or Cr eat i ng Sal es Or der ' . * Report Error message

CALL METHOD l _message_manager - >r epor t _er r or _message EXPORTI NG message_t ext = v_message_t ext . ENDI F. ENDMETHOD.

Step 4 – Creating Views Create a view named MAIN_VIEW and map the all node from the component controller to it.

Now design the layout as shown below. Create 4 Groups one for each node and add a button named CREATE to it.

SAP DEVELOPER NETWORK | sdn.sap.com

© 2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY  | bpx.sap.com

8

Sales Order Creation usin g ABAP WebDynpro

Create an ACTION named CREATE_SALES_ORD for the CREATE button.

The implementation for the ONACTIONCREATE_SALES_ORD method is given below, METHOD  onact i oncr eat e_sal es_or d . * Here we call the component Controller Method  * that will create the sales order 

wd_comp_cont r ol l er - >cr eat e_sal es_or der ( ). ENDMETHOD.

Step 5 - Assigning Views to Window Now drag the MAIN_VIEW and drop it on the Window SO_CREATE. SAP DEVELOPER NETWORK | sdn.sap.com

© 2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY  | bpx.sap.com

9

Sales Order Creation usin g ABAP WebDynpro

Step 6 – Create WebDynpro Application Create a Web Dynpro application and Test the program.

SAP DEVELOPER NETWORK | sdn.sap.com

© 2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY  | bpx.sap.com

10

Sales Order Creation usin g ABAP WebDynpro

Related Content Please include at least three references to SDN documents or web pages. https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/cb243c45-0801-0010-eb9c88669007f130 https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/7a89b067-0801-0010-8192a9896a60938e http://help.sap.com/saphelp_nw04s/helpdata/en/77/3545415ea6f523e10000000a155106/frameset.htm https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/a282c952-0801-0010-1eb587953e036712

SAP DEVELOPER NETWORK | sdn.sap.com

© 2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY  | bpx.sap.com

11

Sales Order Creation usin g ABAP WebDynpro

Disclaimer and Liabili ty Notice This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade. SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk. SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.

SAP DEVELOPER NETWORK | sdn.sap.com

© 2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY  | bpx.sap.com

12

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF