Skip to Content
0
Aug 10, 2013 at 06:22 AM

Problem related to bdc

171 Views

Hi all,

i have written a BDC, in which i wants to get error details, for which i have written these code lines.

But i am not getting error result, can anyone sujjest me where i am wrong in these code lines.

report ZFB01_POST_DOCUMENT

no standard page heading line-size 255.

TYPE-POOLS : TRUXS.

TYPES: BEGIN OF str_final,

bldat(10) TYPE c, "Document Date in Document

blart(02) TYPE c, "Document Type

bukrs(04) TYPE c, "Company Code

budat(10) TYPE c, "Posting Date in the Document

monat(2) TYPE c, "Period

waers(5) TYPE c, "Currency key

xblnr(16) TYPE c, "REFERENCE NUM

newbs(02) TYPE c, "Posting Key for the Next Line Item

newko(17) TYPE c, "Account or Matchcode for the Next Line Item

wrbtr(18) TYPE c, "Amount

gsber(04) TYPE c, "Business Area

zterm(04) TYPE c, "Payment term

zfbdt(10) TYPE c, "Baseline Date for Due Date Calculation

zuonr TYPE bseg-zuonr, "Assignment

sgtxt(35) TYPE c, "Text

newbs1(02) TYPE c, "Posting Key for the Next Line Item

newko1(17) TYPE c, "Account or Matchcode for the Next Line Item

wrbtr1(18) TYPE c, "Amount

mwskz(02) TYPE c, "Tax Code

txjcd(15) TYPE c, "Tax Juridiction

zuonr1(20) TYPE c, "Assignment

sgtxt1(35) TYPE c, "Text

newbs2(02) TYPE c, "Posting Key for the Next Line Item

newko2(17) TYPE c, "Account or Matchcode for the Next Line Item

gsber1(04) TYPE c, "Business Area

kostl(10) type c, "cost center

wrbtr2(18) TYPE c, "Amount

mwskz1(02) TYPE c, "Tax Code

txjcd1(15) TYPE c, "Tax Juridiction

valut(10) TYPE c, "Value line Date

zuonr2(20) TYPE C, "ASSIGNMENT

sgtxt2(35) TYPE c, "Text

gsber2(04) TYPE c, "Business Area

kostl1(10) type c, "cost center

END OF str_final.

***DATA : BEGIN OF options.

*** INCLUDE STRUCTURE ctu_params.

***DATA : END OF options.

******DATA: i_messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE,

****** l_message LIKE bapiret2-message.

******DATA: p_mode TYPE c.

DATA : it_final TYPE STANDARD TABLE OF str_final WITH HEADER LINE.

DATA : IT_FILE LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.

***** DATA : BEGIN OF i_error_messtab OCCURS 0.

***** INCLUDE STRUCTURE bdcmsgcoll.

***** DATA : END OF i_error_messtab.

*DATA: p_mode TYPE c.

DATA : BEGIN OF options.

INCLUDE STRUCTURE ctu_params.

DATA : END OF options.

DATA: i_messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE,

l_message LIKE bapiret2-message.

DATA: p_mode TYPE c.

DATA BEGIN OF it_error OCCURS 1.

DATA : text(100) TYPE c.

DATA END OF it_error.

DATA BEGIN OF it_success OCCURS 1.

DATA: text(100) TYPE c.

DATA END OF it_success.

DATA: it_raw TYPE truxs_t_text_data.

DATA : bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.

DATA : messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.

DATA : bmode(1).

**** DATA: i_messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE,

**** l_message LIKE bapiret2-message.

DATA : no_recs1(10),

count(10),

fl_error TYPE i,

text1(100),

counter(2).

SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text-001.

SELECTION-SCREEN SKIP 1.

PARAMETERS : p_file like IBIPPARMS-PATH. "TYPE string.

SELECTION-SCREEN END OF BLOCK blk.

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-002.

PARAMETERS : mode1 RADIOBUTTON GROUP a,

mode2 RADIOBUTTON GROUP a.

SELECTION-SCREEN END OF BLOCK blk1.

*&---------------------------------------------------------------------*

*& Form UPLOAD_DATA

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

AT SELECTION-SCREEN.

IF mode1 NE space.

bmode = 'A'.

ELSE.

bmode = 'N'.

ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

PERFORM get_f4.

start-of-selection.

PERFORM get_file.

PERFORM SUCCESS_TEXT.

PERFORM ERROR_TEXT.

*start-of-selection.

*perform open_group.

LOOP AT it_final.

perform bdc_dynpro using 'SAPMF05A' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWKO'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BKPF-BLDAT'

it_final-BLDAT. "'29.05.2013'.

perform bdc_field using 'BKPF-BLART'

it_final-BLART. "'R1'.

perform bdc_field using 'BKPF-BUKRS'

it_final-BUKRS. "'1100'.

perform bdc_field using 'BKPF-BUDAT'

it_final-BUDAT. "'29.05.2013'.

perform bdc_field using 'BKPF-MONAT'

it_final-MONAT. "'2'.

perform bdc_field using 'BKPF-WAERS'

it_final-WAERS. "'INR'.

perform bdc_field using 'BKPF-XBLNR'

it_final-XBLNR. "'123'.

perform bdc_field using 'FS006-DOCID'

'*'.

perform bdc_field using 'RF05A-NEWBS'

it_final-NEWBS. "'01'.

perform bdc_field using 'RF05A-NEWKO'

it_final-NEWKO. "'4000000612'.

perform bdc_dynpro using 'SAPMF05A' '0301'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWKO'.

perform bdc_field using 'BDC_OKCODE'

'=S+'.

perform bdc_field using 'BSEG-WRBTR'

it_final-WRBTR. "'20000'.

perform bdc_field using 'BSEG-GSBER'

it_final-GSBER. "'1105'.

perform bdc_field using 'BSEG-ZTERM'

it_final-ZTERM. "'0001'.

perform bdc_field using 'BSEG-ZFBDT'

it_final-ZFBDT. "'29.05.2013'.

perform bdc_field using 'BSEG-ZUONR'

it_final-ZUONR. "'1234'.

perform bdc_field using 'BSEG-SGTXT'

it_final-SGTXT. "'TEST1'.

perform bdc_field using 'RF05A-NEWBS'

it_final-NEWBS1. "'50'.

perform bdc_field using 'RF05A-NEWKO'

it_final-NEWKO1. "'3210025'.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWKO'.

perform bdc_field using 'BDC_OKCODE'

'=S+'.

perform bdc_field using 'BSEG-WRBTR'

it_final-WRBTR1. "'15000'.

perform bdc_field using 'BSEG-MWSKZ'

it_final-MWSKZ. "'A0'.

perform bdc_field using 'BSEG-TXJCD'

it_final-TXJCD. "'9000'.

perform bdc_field using 'BSEG-ZUONR'

it_final-ZUONR1. "'12345'.

perform bdc_field using 'BSEG-SGTXT'

it_final-SGTXT1. "'TEST2'.

perform bdc_field using 'RF05A-NEWBS'

it_final-NEWBS2. "'50'.

perform bdc_field using 'RF05A-NEWKO'

it_final-NEWKO2. "'1215030'.

perform bdc_dynpro using 'SAPLKACB' '0002'.

perform bdc_field using 'BDC_CURSOR'

'COBL-KOSTL'.

perform bdc_field using 'BDC_OKCODE'

'=ENTE'.

perform bdc_field using 'COBL-GSBER'

it_final-GSBER1. "'1105'.

perform bdc_field using 'COBL-KOSTL'

it_final-KOSTL. "'11-R001'.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWKO'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_field using 'BSEG-WRBTR'

it_final-WRBTR2. "'5000'.

perform bdc_field using 'BSEG-MWSKZ'

it_final-MWSKZ1. "'A0'.

perform bdc_field using 'BSEG-TXJCD'

it_final-TXJCD1. "'9000'.

perform bdc_field using 'BSEG-VALUT'

it_final-VALUT. "'29.05.2013'.

perform bdc_field using 'BSEG-ZUONR'

it_final-ZUONR2. "'123456'.

perform bdc_field using 'BSEG-SGTXT'

it_final-SGTXT2. "'TEST3'.

perform bdc_field using 'RF05A-NEWBS'

it_final-NEWBS1. "'50'.

perform bdc_field using 'RF05A-NEWKO'

it_final-NEWKO1. "'3210025'.

perform bdc_field using 'DKACB-FMORE'

'X'.

perform bdc_dynpro using 'SAPLKACB' '0002'.

perform bdc_field using 'BDC_CURSOR'

'COBL-KOSTL'.

perform bdc_field using 'BDC_OKCODE'

'=ENTE'.

perform bdc_field using 'COBL-GSBER'

it_final-GSBER. "'1105'.

perform bdc_field using 'COBL-KOSTL'

it_final-KOSTL. "'11-R001'.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_OKCODE'

'/EPOS'.

perform bdc_field using 'BDC_CURSOR'

'BSEG-WRBTR'.

perform bdc_dynpro using 'SAPMF05A' '0700'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWBS'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_field using 'BKPF-XBLNR'

it_final-XBLNR. "'123'.

*perform bdc_transaction using 'FB01'.

CALL TRANSACTION 'FB01' USING bdcdata MODE bmode MESSAGES INTO i_messtab.

CLEAR bdcdata.

REFRESH bdcdata.

CLEAR it_final.

IF SY-SUBRC NE 0.

CALL FUNCTION 'BAPI_MESSAGE_GETDETAIL'

EXPORTING

ID = sy-msgid

NUMBER = sy-msgno

LANGUAGE = SY-LANGU

TEXTFORMAT = 'ASC'

* LINKPATTERN =

MESSAGE_V1 = sy-msgv1

MESSAGE_V2 = sy-msgv2

MESSAGE_V3 = sy-msgv3

MESSAGE_V4 = sy-msgv4

IMPORTING

MESSAGE = l_message.

* RETURN =

* TABLES

* TEXT =

.

CONCATENATE l_message '-' it_final-newko it_final-wrbtr it_final-budat INTO it_error-text

SEPARATED BY ' '.

APPEND it_error.

ELSE.

CONCATENATE 'DATA UPLOADED SUCCESSFULLY :' it_final-newko it_final-wrbtr it_final-budat

INTO it_success-text SEPARATED BY ' '.

APPEND it_success.

ENDIF.

REFRESH bdcdata.

CLEAR: it_final,l_message.

ENDLOOP.

" UPLOAD_DATA

FORM success_text .

LOOP AT it_success.

AT FIRST.

WRITE :/10 'Following records successfully uploaded'.

ULINE.

ENDAT.

WRITE :/10 it_success-text.

ENDLOOP.

ENDFORM.

FORM error_text .

LOOP AT it_error.

AT FIRST.

WRITE :/10 'Following records are not uploaded'.

ULINE.

ENDAT.

WRITE :/10 it_error-text.

ENDLOOP.

ENDFORM.

*perform close_group.

FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM.

FORM BDC_FIELD USING FNAM FVAL.

IF FVAL <> SPACE.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

ENDIF.

ENDFORM.

form get_f4.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

FIELD_NAME = 'P_FILE'

IMPORTING

FILE_NAME = P_FILE

.

ENDFORM.

FORM get_file .

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

FILENAME = P_FILE

I_BEGIN_COL = 1

I_BEGIN_ROW = 2

I_END_COL = 100

I_END_ROW = 6000

TABLES

INTERN = IT_FILE

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOOP AT IT_FILE.

CASE IT_FILE-COL.

WHEN 1.

it_final-BLDAT = IT_FILE-VALUE.

WHEN 2.

it_final-BLART = IT_FILE-VALUE.

WHEN 3.

it_final-BUKRS = IT_FILE-VALUE.

WHEN 4.

it_final-BUDAT = IT_FILE-VALUE.

WHEN 5.

it_final-MONAT = IT_FILE-VALUE.

WHEN 6.

it_final-WAERS = IT_FILE-VALUE.

WHEN 7.

it_final-XBLNR = IT_FILE-VALUE.

WHEN 8.

it_final-NEWBS = IT_FILE-VALUE.

WHEN 9.

it_final-NEWKO = IT_FILE-VALUE.

WHEN 10.

it_final-WRBTR = IT_FILE-VALUE.

WHEN 11.

it_final-GSBER = IT_FILE-VALUE.

WHEN 12.

it_final-ZTERM = IT_FILE-VALUE.

WHEN 13.

it_final-ZFBDT = IT_FILE-VALUE.

WHEN 14.

it_final-ZUONR = IT_FILE-VALUE.

WHEN 15.

it_final-SGTXT = IT_FILE-VALUE.

WHEN 16.

it_final-NEWBS1 = IT_FILE-VALUE.

WHEN 17.

it_final-NEWKO1 = IT_FILE-VALUE.

WHEN 18.

it_final-WRBTR1 = IT_FILE-VALUE.

WHEN 19.

it_final-MWSKZ = IT_FILE-VALUE.

WHEN 20.

it_final-TXJCD = IT_FILE-VALUE.

WHEN 21.

it_final-ZUONR1 = IT_FILE-VALUE.

WHEN 22.

it_final-SGTXT1 = IT_FILE-VALUE.

WHEN 23.

it_final-NEWBS2 = IT_FILE-VALUE.

WHEN 24.

it_final-NEWKO2 = IT_FILE-VALUE.

WHEN 25.

it_final-GSBER1 = IT_FILE-VALUE.

WHEN 26.

it_final-KOSTL = IT_FILE-VALUE.

WHEN 27.

it_final-WRBTR2 = IT_FILE-VALUE.

WHEN 28.

it_final-MWSKZ1 = IT_FILE-VALUE.

WHEN 29.

it_final-txjcd1 = IT_FILE-VALUE.

WHEN 30.

it_final-valut = IT_FILE-VALUE.

WHEN 31.

it_final-zuonr2 = IT_FILE-VALUE.

WHEN 32.

it_final-sgtxt2 = IT_FILE-VALUE.

WHEN 33.

it_final-gsber2 = IT_FILE-VALUE.

WHEN 34.

it_final-KOSTL1 = IT_FILE-VALUE.

APPEND it_final.

CLEAR it_final.

ENDCASE.

ENDLOOP.

ENDFORM. " SUCCESS_TEXT