Go on link..

link us with ...

Monday, December 13, 2010

SESSION CALL METHOD 2 BDC Programming



REPORT ZSJ_ZFB01_METHOD2
NO STANDARD PAGE HEADING LINE-SIZE 255.

INCLUDE BDCRECX1.


DATA :IT_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA : IDX LIKE SY-TABIX.

DATA : BEGIN OF ITAB OCCURS 0 ,

BLDAT(8) TYPE C , " LIKE BKPF-BLDAT,
BLART(2) TYPE C , "LIKE BKPF-BLART,
BUKRS(4) TYPE C, "LIKE BKPF-BUKRS,
XBLNR(16) TYPE C , "LIKE BKPF-XBLNR,
BKTXT(25) TYPE C , "LIKE BKPF-BKTXT,
NEWBS(2) TYPE C , "LIKE RF05A-NEWBS,
NEWKO(17) TYPE C , "LIKE RF05A-NEWKO,
WRBTR(13) TYPE C, " LIKE BSEG-WRBTR,
GSBER(4) TYPE C , " LIKE COBL-GSBER,
PRCTR(10) TYPE C , "LIKE COBL-PRCTR,
KOSTL(10) TYPE C , "LIKE COBL-KOSTL,

END OF ITAB .






SELECTION-SCREEN BEGIN OF BLOCK GR WITH FRAME TITLE TEXT-001.
PARAMETERS: P_FILE TYPE STRING . " LIKE RLGRAP-FILENAME OBLIGATORY.
SELECTION-SCREEN END OF BLOCK GR.




*----------------------------------------------------------------------*
* At Selection-screen *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
PERFORM F4_HELP_P_FILE.


START-OF-SELECTION.

PERFORM GUI_UPLOAD.
PERFORM SESSION_METHOD .


*&---------------------------------------------------------------------*
*& Form CALL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SESSION_METHOD .


PERFORM OPEN_GROUP.

LOOP AT ITAB .

REFRESH BDCDATA.
CLEAR BDCDATA.

IDX = SY-INDEX .
IDX = IDX + 1 .


PERFORM BDC_DYNPRO USING 'ZSAPMF05A' '0100'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'BKPF-BLDAT'
* '04.12.2008'.
ITAB-BLDAT.
PERFORM BDC_FIELD USING 'BKPF-BLART'
* 'kr'.
ITAB-BLART.
PERFORM BDC_FIELD USING 'BKPF-BUKRS'
* 'TCIL'.
ITAB-BUKRS.
PERFORM BDC_FIELD USING 'BKPF-BUDAT'
'04.12.2008'.
* ITAB-BUDAT.
PERFORM BDC_FIELD USING 'BKPF-MONAT'
'12'.
PERFORM BDC_FIELD USING 'BKPF-WAERS'
'INR'.
PERFORM BDC_FIELD USING 'BKPF-XBLNR'
* 'test'.
ITAB-XBLNR.
PERFORM BDC_FIELD USING 'BKPF-BKTXT'
* 'test'.
ITAB-BKTXT.
PERFORM BDC_FIELD USING 'FS006-DOCID'
'*'.

PERFORM BDC_FIELD USING 'RF05A-NEWBS'
* '40'.
ITAB-NEWBS .
PERFORM BDC_FIELD USING 'RF05A-NEWKO'
* '44630005'.
ITAB-NEWKO.



PERFORM BDC_DYNPRO USING 'ZSAPMF05A' '0300'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
PERFORM BDC_FIELD USING 'BSEG-WRBTR'
* '500'.
ITAB-WRBTR .
*
DELETE ITAB INDEX IDX.
CLEAR :ITAB.
READ TABLE ITAB .

PERFORM BDC_FIELD USING 'RF05A-NEWBS'
* '50'.
ITAB-NEWBS .
PERFORM BDC_FIELD USING 'RF05A-NEWKO'
* '44640002'.
ITAB-NEWKO.



PERFORM BDC_DYNPRO USING 'SAPLKACB' '0002'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'COBL-PRCTR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTE'.
PERFORM BDC_FIELD USING 'COBL-GSBER'
* 'fxrt'.
ITAB-GSBER .
PERFORM BDC_FIELD USING 'COBL-KOSTL'
* 'rt0001ops'.
ITAB-KOSTL.
PERFORM BDC_FIELD USING 'COBL-PRCTR'
* 'rt0001'.
ITAB-PRCTR.


PERFORM BDC_DYNPRO USING 'ZSAPMF05A' '0300'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'BSEG-WRBTR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
PERFORM BDC_FIELD USING 'BSEG-WRBTR'
* '*'.
ITAB-WRBTR.


PERFORM BDC_DYNPRO USING 'SAPLKACB' '0002'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'COBL-PRCTR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTE'.
PERFORM BDC_FIELD USING 'COBL-GSBER'
* 'fxrt'.
ITAB-GSBER .
PERFORM BDC_FIELD USING 'COBL-KOSTL'
* 'rt0001ops'.
ITAB-KOSTL.
PERFORM BDC_FIELD USING 'COBL-PRCTR'
* 'rt0001'.
ITAB-PRCTR.
PERFORM BDC_TRANSACTION USING 'ZFB01'.

CLEAR : BDCDATA .
DELETE ITAB INDEX IDX.
CLEAR :ITAB.
READ TABLE ITAB .



ENDLOOP.

PERFORM CLOSE_GROUP.


IF SY-SUBRC EQ 0.

WRITE:/ 'SESSION CREATED IN SM35'.

ELSE.

WRITE:/ 'SESSION NOT CREATED, ERRORS OCCURED'.

ENDIF.



ENDFORM. " CALL
*&---------------------------------------------------------------------*
*& Form F4_HELP_P_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM F4_HELP_P_FILE .




DATA : V_FILE(128) TYPE C . "LIKE P_FILE.
* Display popup with files list to select
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = V_FILE.
CHECK SY-SUBRC EQ 0.

P_FILE = V_FILE.

ENDFORM. " F4_HELP_P_FILE
*&---------------------------------------------------------------------*
*& Form GUI_UPLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GUI_UPLOAD .

CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = P_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = ITAB
* EXCEPTIONS
* FILE_OPEN_ERROR = 1
* FILE_READ_ERROR = 2
* NO_BATCH = 3
* GUI_REFUSE_FILETRANSFER = 4
* INVALID_TYPE = 5
* NO_AUTHORITY = 6
* UNKNOWN_ERROR = 7
* BAD_DATA_FORMAT = 8
* HEADER_NOT_ALLOWED = 9
* SEPARATOR_NOT_ALLOWED = 10
* HEADER_TOO_LONG = 11
* UNKNOWN_DP_ERROR = 12
* ACCESS_DENIED = 13
* DP_OUT_OF_MEMORY = 14
* DISK_FULL = 15
* DP_TIMEOUT = 16
* OTHERS = 17
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


ENDFORM. " GUI_UPLOAD




04122008 JV TCIL test test 40 44640002 500 fxrt rt0001 rt0001ops
04122008 JV TCIL test test 50 16220400 500 fxrt rt0001 rt0001ops
04122008 JV TCIL test test 40 44630005 100 fxrt rt0001 rt0001ops
04122008 JV TCIL test test 50 16220400 100 fxrt rt0001 rt0001ops

No comments:

link us...

For Visitors

if you want to publish or Add something on ERP, SAP , SAP FUNCTIONAL, SAP ABAP then mail us along with your email-id. contain must be yours

email-id :- avinashkr_raj@yahoo.com(any email)

email-id :- avinaskr_raj.abap@blogger.com ( use only gmail)