bdc program with ooabap
DESCRIPTION
BDCTRANSCRIPT
-
5/25/2018 BDC Program With OOABAP
1/8
BDC Program with OOABAP:
This tutorial is all about to write BDC program with OOPs in ABAP. In one of my projects I got arequirement that while we creating a PO with respect to a quotation the unuse! quotations of
same "#$ shoul! be mar%e! as "ejecte!. To Implement this I foun! a BADI unfortunately we
!on&t ha'e BAPI&s to up!ate quotations so we shoul! opt BDC to up!ate $uotations. usually BDC
programs will be written by using two subroutines to fill BDCDATA internal table one is for screen
information an! other one is for fiel! name an! 'alue the problem is that BADI class metho!s
won&t allow perform an! from statements so we shoul! write the same co!e in OOABAP.
(o what I !i! here is that simply I ha'e con'erte! those two subroutines into two metho!s in a
class. Initially I create! a )*class in that I ha'e create! require! attributes an! metho!s. Please
follow below steps you can un!erstan!
Class Attributes
Class Methods
Class Methods Implementation
http://scn.sap.com/community/abap/blog/2013/10/11/bdc-program-with-ooabaphttp://scn.sap.com/servlet/JiveServlet/showImage/38-94089-291818/2.jpghttp://scn.sap.com/servlet/JiveServlet/showImage/38-94089-291709/1.jpghttp://scn.sap.com/community/abap/blog/2013/10/11/bdc-program-with-ooabap -
5/25/2018 BDC Program With OOABAP
2/8
method BDC_DYNPRO.
wa_bdcdata-program = program. " Program name
wa_bdcdata-dynpro = dynpro. " Screen Number
wa_bdcdata-dynbegin = 'X'. " X
*** Append bdc table and clear work area
PP!ND wa_bdcdata "O it_bdcdata.
C#!R wa_bdcdata.
endmethod.
method BDC_$%!#D!.
wa_bdcdata-(nam = (nam. " Field Name
wa_bdcdata-()a* = ()a*. " Field Value
PP!ND wa_bdcdata "O it_bdcdata.
C#!R wa_bdcdata.endmethod.
+ow I simply use! this class in my BADI Class ,etho! an! sol'e the problem .
-ere it is a sample co!e for BDC into OOABAP to up!ate quotations Tco!e
,/0.
DATA1 ob*b!c T2P "# TO 3cl*b!c*bps.
C"AT OB4CT ob*b!c.
T2P(1 B5I+ O# t*e%%o
ebeln T2P e%po6ebeln
+D O# t*e%%o
B5I+ O# t*e%po
ebeln T2P e%po6ebeln
ebelp T2P e%po6ebelp
+D O# t*e%po.
!ata1 it*e%%o T2P TAB7 O# t*e%%o
it*e%po T2P TAB7 O# t*e%po
it*message T2P TAB7 O# t*message
-
5/25/2018 BDC Program With OOABAP
3/8
it*b!c!ata T2P (TA+DA"D TAB7 O# b!c!ata I+ITIA7 (I) 8
it*b!c*messages T2P (TA+DA"D TAB7 O# b!cmsgcoll I+ITIA7 (I) 8
wa*message T2P t*message
wa*e%po9 T2P t*e%po
wa*e%%o T2P t*e%%o
wa*e%po T2P e%po
w*anfnr T2P e%po6anfnr
w*submi T2P e%%o6submi
w*mo!e:9; T2P c 9.
I# sy6subrc $ 8.
C7A" w*submi.
(7CT (I+57 submi I+TO w*submi #"O, e%%o ?-" ebeln @
wa*e%po6anfnr.
I# sy6subrc $ 8.
(7CT ebeln #"O, e%%o I+TO TAB7 it*e%%o ?-" submi @
w*submi.
I# sy6subrc $ 8.
(7CT ebeln ebelp #"O, e%po I+TO TAB7 it*e%po
#O" A77 +T"I( I+ it*e%%o
?-" ebeln @ it*e%%o6ebeln.
!elete it*e%%o where ebeln @ wa*e%po6anfnr.
!elete it*e%po where ebeln @ wa*e%po6anfnr.
7OOP AT it*e%%o I+TO wa*e%%o.
C7A"1ob*b!c6it*b!c!ata.
Populate BDC !ata to ,aintain $uotation in ,/0
-
5/25/2018 BDC Program With OOABAP
4/8
CA77 ,T-OD ob*b!c6b!c*!ynpro
EPO"TI+5
program @ &(AP,,8F&
!ynpro @ &8G8H&
!ynbegin @ &E&.
CA77 ,T-OD ob*b!c6b!c*fiel!'alue
EPO"TI+5
fnam @ &BDC*C="(O"&
f'al @ &",8F6A+#+"&.
CA77 ,T-OD ob*b!c6b!c*fiel!'alue
EPO"TI+5
fnam @ &BDC*OCOD&
f'al @ &J88&.
w*ebelp @ wa*e%%o6ebeln.
CO+D+( w*ebelp.
CA77 ,T-OD ob*b!c6b!c*fiel!'alue
EPO"TI+5
fnam @ &",8F6A+#+"&
f'al @ w*ebelp.
C7A"1w*ebelp.
7OOP AT it*e%po I+TO wa*e%po9 ?-" ebeln $ wa*e%%o6ebeln.
CA77 ,T-OD ob*b!c6b!c*!ynpro
-
5/25/2018 BDC Program With OOABAP
5/8
EPO"TI+5
program @ &(AP,,8F&
!ynpro @ &8GKG&
!ynbegin @ &E&.
CA77 ,T-OD ob*b!c6b!c*fiel!'alue
EPO"TI+5
fnam @ &BDC*C="(O"&
f'al @ &",8F6B7P&.
CA77 ,T-OD ob*b!c6b!c*fiel!'alue
EPO"TI+5
fnam @ &BDC*OCOD&
f'al @ &J88&.
w*ebelp @ w*ebelp L 98.
CO+D+( w*ebelp.
CA77 ,T-OD ob*b!c6b!c*fiel!'alueEPO"TI+5
fnam @ &",8F6B7P&
f'al @ w*ebelp.
-
5/25/2018 BDC Program With OOABAP
6/8
CA77 ,T-OD ob*b!c6b!c*!ynpro
EPO"TI+5
program @ &(AP,,8F&
!ynpro @ &8GKG&
!ynbegin @ &E&.
CA77 ,T-OD ob*b!c6b!c*fiel!'alue
EPO"TI+5
fnam @ &BDC*C="(O"&
f'al @ &PO6,AT+&.
CA77 ,T-OD ob*b!c6b!c*fiel!'alue
EPO"TI+5
fnam @ &BDC*OCOD&
f'al @ &@DTA&.
CA77 ,T-OD ob*b!c6b!c*fiel!'alue
EPO"TI+5
fnam @ &",8F6B7P&
f'al @ w*ebelp.
CA77 ,T-OD ob*b!c6b!c*!ynpro
EPO"TI+5
program @ &(AP,,8F&
!ynpro @ &8G99&
-
5/25/2018 BDC Program With OOABAP
7/8
!ynbegin @ &E&.
CA77 ,T-OD ob*b!c6b!c*fiel!'alue
EPO"TI+5
fnam @ &BDC*C="(O"&
f'al @ &",8F6A+,+5&.
CA77 ,T-OD ob*b!c6b!c*fiel!'alue
EPO"TI+5
fnam @ &PO6AB()&
f'al @ &E&.
+D7OOP.
CA77 ,T-OD ob*b!c6b!c*fiel!'alue
EPO"TI+5
fnam @ &BDC*OCOD&
f'al @ &@B=&.
refresh it*b!c!ata.
it*b!c!ata @ ob*b!c6it*b!c!ata.
-
5/25/2018 BDC Program With OOABAP
8/8
CA77 T"A+(ACTIO+ c*me/0 =(I+5 it*b!c!ata
,OD w*mo!e
=PDAT w*up!ate
,((A5( I+TO it*b!c*messages.
en!loop.