• No results found

Sales Order Creation Using Web Dynpro ABAP

N/A
N/A
Protected

Academic year: 2021

Share "Sales Order Creation Using Web Dynpro ABAP"

Copied!
12
0
0

Loading.... (view fulltext now)

Full text

(1)

SAP DEVELOPER NETWORK

SAP DEVELOPER NETWORK | sdn.sap.com| sdn.sap.com BUSINESS BUSINESS PROCESS PROCESS EXPERT EXPERT COMMUNITYCOMMUNITY | bpx.sap.com| bpx.sap.com

©

© 2006 2006 SAP SAP AG AG 11

Sales Order Creation using Web Dynpro ABAP

Sales Order Creation using Web Dynpro ABAP

 Ap

 Ap

pl

pl

ies

ies

to

to

:

:

SAP NetWeaver 2004s, Web Dynpro ABAP SAP NetWeaver 2004s, Web Dynpro ABAP

Summary

Summary

This step by step exercise helps to create a sales order application using Web Dynpro ABAP. This step by step exercise helps to create a sales order application using Web Dynpro ABAP.

 Au

 Au thth oror :: Kathirvel BalakrishnanKathirvel Balakrishnan

Company:

Company: Wipro TechnologiesWipro Technologies

Created on:

Created on: 07 February 2007 07 February 2007

 Au

 Au

th

th

or

or

Bi

Bi

o

o

Kathirvel Balakrishnan is working as a ABAP Consultant for Wipro Technologies. His areas Kathirvel Balakrishnan is working as a ABAP Consultant for Wipro Technologies. His areas of interests are ABAP ( Object, WebD

(2)

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

(3)

Prerequisite

This example requires basic knowledge about ABAP.

Sampl e Screen Shots

The Web Dynpro ABAP Sales Order creation application,

(4)

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

(5)

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

(6)

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

* <ORDER_HEADER> 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 ) . * <ORDER_ITEMS> 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 ) . * <ORDER_PARTNERS> 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 ) . * <ORDER_CONDITIONS> 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 par nr , w_or der _par t ners  TYPE  bapi par nr ,

i _ r e t ur n  TYPE  TABLE OF  bapi r et 2,

w_r et ur n  TYPE  bapi r et 2,

i _or der _i t ems_i n  TYPE  TABLE OF  bapi sdi t m, 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 cond, w_or der _condi t i ons_i n  TYPE  bapi cond.

* Order Header Details CLEAR  w_or der _header _i n.

(7)

w_or der_ header _i n- doc_t ype = st r u_or der _header - doc_t ype. w_order _header _i n- sal es_or g = st r u_order _header - sal es_or g. w_order _header _i n- di st r _chan = st r u_order _header - di st r _chan. w_or der _header _i n- di vi si on = st r u_or der _header - di vi si on. w_or der_ header _i n- r eq_dat e_h = st r u_or der _header - r eq_dat e_h. w_order _header _i n- sal es_di st = 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 t i ons_i n, w_or der _condi t i ons_i n.

w_or der_ condi t i ons_i n- i t m_number = st r u_or der_ condi t i ons- i t m_number . w_order _condi t i ons_i n- cond_t ype = st r u_order _condi t i ons- cond_t ype. w_order _condi t i ons_i n- cond_val ue = st r u_order _condi t i ons- cond_val ue. APPEND  w_or der _condi 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

r e t u r n = 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

(8)

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.

(9)

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

(10)

Step 6 – Create WebDynpro Application

(11)

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-eb9c-88669007f130 https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/7a89b067-0801-0010-8192-a9896a60938e 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-1eb5-87953e036712

(12)

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.

References

Related documents

Let’s begin with a list of common lubrica- tion and oil analysis decisions (all attributes of the ORS) that can be customized (opti- mized) by understanding failure modes

Parent Component UI Com ponen t Usage UI Com ponen t Usage Controller Window Child Com ponen t Usage Child Com ponen t Usage Component Interface View Component Interface

In this step you create and assign new User Interfaces, based on Web Dynpro Java, for the human activities.. This UI wizard was introduced

The Wasserstein distance induced from optimal transport problem is also introduced, which is used to estimate the difference be- tween multivariate functions obtained from

Section 118(3) should then preferably kick in at this stage when the property is sold and transferred, and it is at this time when the municipality should enforce its charge

T he New England Board of Higher Education’s Tuition Break program, the New England Regional Student Program (RSP), provides a discount on tuition to New England residents, when

Furthermore, we thank the Financial Markets Infrastructure Division at the Bank of England for their hospitality where some of this research was initiated.. The usual

Religion, Science, and Truth in the Human Experience: Poetry as Living Synthesis in Walt Whitman’s Leaves of Grass..