Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

error correction in bdc session

former_member196299
Active Contributor
0 Kudos

Hi ,

i have created a bdc in session method and even have processed the session,

in that i have got some error records. I want to collect and display these errors, anyone help me asap in resolving the problem or whats the general way to resolve the error records in session will also do.

thanks

Ranjita

10 REPLIES 10

Former Member
0 Kudos

Hi Ranjita

Please go throught the log of session to understand the errors.

Few might be due to missing master data or config or data entry...

Kind Regards

Eswar

0 Kudos

thanks for the reply Eswar,

but i want the error records to be collected from the session and then display them , is there any way i can do that ?

0 Kudos

HI Ranjita

Please go through program: <b>RSBDC_ANALYSE & RSBDCDRU</b> for some understanding on the same...

I guess the logs will be stored in files on server and not directly in database tables. Though we can get some references from tables like APQI and APQL.

Kind Regards

Eswar

0 Kudos

Hi

Here is a sample program wherein you can download the errors into a internal table from the batch session method using the queue id from the batch session

You can change the program so that it suits your requirements.

PARAMETERS:

queue_id LIKE apqi-qid OBLIGATORY.

INCLUDE rsbdcil3. "Read plain log from TemSe

TYPE-POOLS: icon, sdydo.

TABLES:

apqi, apqd, apql, t100, snap.

CONTROLS:

tc_tcodes TYPE TABLEVIEW USING SCREEN 200,

tc_dynpro TYPE TABLEVIEW USING SCREEN 300,

tc_protocol TYPE TABLEVIEW USING SCREEN 400,

tc_bdcld TYPE TABLEVIEW USING SCREEN 600,

tc_q_tcodes TYPE TABLEVIEW USING SCREEN 700,

tab_dynpro TYPE TABSTRIP,

tab_apqi TYPE TABSTRIP.

FIELD-SYMBOLS:

.

DATA:

  • this table keeps those tcodes actually displayed

BEGIN OF bdc_tcodes OCCURS 0,

index TYPE i, tcode LIKE sy-tcode, status(1), s_text(16),

END OF bdc_tcodes,

  • this table keeps all tcodes of the session

BEGIN OF all_bdc_tcodes OCCURS 0,

index TYPE i, tcode LIKE sy-tcode, status(1), s_text(16),

END OF all_bdc_tcodes.

DATA:

  • this table keeps those dynpros actually displayed

BEGIN OF bdc_dynpro OCCURS 0,

program LIKE sy-cprog, dynpro LIKE sy-dynnr,

fnam LIKE bdcdata-fnam, fval LIKE bdcdata-fval,

index TYPE i,

END OF bdc_dynpro,

  • this table keeps all dynpros of the session

BEGIN OF all_bdc_dynpro OCCURS 0,

program LIKE sy-cprog, dynpro LIKE sy-dynnr,

fnam LIKE bdcdata-fnam, fval LIKE bdcdata-fval,

index TYPE i,

END OF all_bdc_dynpro,

dynpro_index TYPE i,

cat_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.

DATA:

  • this table keeps protocol lines to be displayed

BEGIN OF bdc_protocol OCCURS 0.

INCLUDE STRUCTURE bdclm.

DATA:

longtext TYPE bdc_mpar,

END OF bdc_protocol.

DATA:

it_apqd LIKE apqd OCCURS 0 WITH HEADER LINE,

udat LIKE apqd-vardata, sdat LIKE apqd-vardata.

DATA:

BEGIN OF tf OCCURS 0, "interne tabelle mit dynprofeldern

count TYPE i VALUE 0, "zum abmischen

trcd(4),stat(4),

pgm(8), "programmname

dyn(4) TYPE n, "dynpronummer

fname(35), farg(132), fstart(5) TYPE p, fende(5) TYPE p,

END OF tf.

  • needed for check if TemSe interface is active:

DATA: protparam(60) VALUE 'bdc/new_protocol',

newprot(3) VALUE 'off'.

  • message header

DATA:

BEGIN OF bdcmh,

mtype, state,

tcode(20), " (4 -> 20)

prog(40), " (8 -> 40)

dynr(4), sepc, filler,

END OF bdcmh.

  • transaction header

DATA:

BEGIN OF bdcth,

mtype, state,

tcode(20), " (4 -> 20)

postg, print,

msgid(20), " (2 -> 20)

END OF bdcth.

DATA:

bdcmhlen TYPE i VALUE 68, " (20 -> 68 ) MessageHeaderlaenge

dcnt TYPE i, tcnt TYPE i, gencnt TYPE i, delcnt TYPE i, wcount TYPE i,

mfstart TYPE i, mfende TYPE i, mflen TYPE i, mfart(2).

DATA BEGIN OF bdclm OCCURS 0. " ITabelle der Messageseintraege

INCLUDE STRUCTURE bdclm. " LogTabelle

DATA: counter TYPE i,

longtext TYPE bdc_mpar,

isdetail(1) TYPE c,

END OF bdclm .

DATA: lm LIKE bdclm,

save_mpar TYPE bdc_mpar.

DATA BEGIN OF bdcld OCCURS 0. " ITabelle der Verzeichniseintraege

INCLUDE STRUCTURE bdcld. " LogTabelle aller Protokolle

DATA: logname(80), " protokollpfad

local_host(12), " lokaler rechner

cnt TYPE i, " satzzaehler

active(1) TYPE c, " active flag

temseid TYPE rstsoname. " TemSe ID

DATA END OF bdcld .

DATA:

logtab LIKE bdcld OCCURS 0 WITH HEADER LINE,

logtab_temse LIKE apql OCCURS 0 WITH HEADER LINE.

DATA:

main_okcode TYPE fcode,

d0500_fcode TYPE fcode,

d0600_fcode TYPE fcode,

d0700_fcode TYPE fcode,

d0701_fcode TYPE fcode,

tc_mark(1),

counter TYPE i,

status_icon(32),

dynprotab_subscreen_dynpro LIKE sy-dynnr,

header_subscreen_dynpro LIKE sy-dynnr.

DATA:

ex_date(12), string(48), tab_proto(48).

  • Radio buttons and checkbox on screen 0500

DATA:

BEGIN OF rb,

tcodes_all VALUE 'X', tcodes_error,

fieldlist VALUE ' ',

pro_all VALUE 'X', pro_tcode, pro_session,

log_detail,

END OF rb.

DATA:

  • Flags for identifying contents of the bdc_... tables

bdc_tcodes_content(1), "a: all, e: errors

bdc_dynpro_content(1), "f: fieldlist, s: screens only

bdc_protocol_content(1), "a: all, t: for transaction, s: for session

bdc_lines LIKE sy-index,

c_field(132),

c_line TYPE i,

selected_index LIKE sy-index,

selected_protocol LIKE sy-index,

tc_index LIKE sy-index,

tc_select LIKE sy-index,

tcode_index LIKE bdc_tcodes-index,

tcode_index_apqd LIKE bdc_tcodes-index,

1st_bdc_tcode_index LIKE bdc_tcodes-index,

i_tcodes TYPE i,

i_protocols TYPE i,

tcode LIKE sy-tcode,

tcode_status(16),

previous_tab(64).

  • Data needed for CATT simulation of screens

DATA:

BEGIN OF bdc_subscreen,

program LIKE sy-cprog,

dynpro LIKE sy-dynnr,

subscr(64),

END OF bdc_subscreen.

  • Table for keeping fcodes to be excluded from pf-status

DATA:

BEGIN OF ex_cua OCCURS 2,

fcode LIKE rsmpe-func,

END OF ex_cua.

  • data for keeping scoll infos

DATA:

current_page LIKE sy-tabix VALUE 1,

new_page LIKE sy-tabix,

total_pages LIKE sy-tabix,

new_line LIKE sy-tabix,

entries LIKE sy-tabix,

loopc LIKE sy-loopc.

  • data for queue dump

DATA:

BEGIN OF q,

tcode_index LIKE all_bdc_tcodes-index,

itab_index LIKE all_bdc_tcodes-index,

c_field(132),

c_line LIKE sy-index,

c_area(132),

wa LIKE LINE OF all_bdc_tcodes,

control_init VALUE 'X',

reuse_control,

uc_bytes TYPE i,

c(1),

show_hex VALUE ' ',

END OF q.

DATA:

t TYPE sdydo_text_element,

c(128).

TYPES:

BEGIN OF block,

dt TYPE REF TO cl_dd_table_element,

dta TYPE REF TO cl_dd_table_area,

END OF block.

DATA:

it_blocks TYPE STANDARD TABLE OF block,

b_wa TYPE block.

DATA:

dd TYPE REF TO cl_dd_document,

cust TYPE REF TO cl_gui_custom_container.

TYPES:

BEGIN OF cx,

char(1) TYPE c,

hex(4) TYPE x,

xtoc(8) TYPE c,

END OF cx,

uc_1(1) TYPE x,

uc_2(2) TYPE x,

uc_4(4) TYPE x.

DATA:

it_cx TYPE STANDARD TABLE OF cx,

cx TYPE cx.

FIELD-SYMBOLS:

.

DATA:

BEGIN OF count,

start TYPE i,

index TYPE i,

part TYPE i,

rest TYPE i,

END OF count.

DATA:

cspan TYPE i.

CONSTANTS:

nr_cols TYPE i VALUE 64,

reload_apqi VALUE 'X'.

DATA:

BEGIN OF apqdcnt,

transcntb TYPE apq_tran, "neu

msgcntb TYPE apq_reco,

transcnte TYPE apq_tran, "fehlerhaft

msgcnte TYPE apq_reco,

transcnto TYPE apq_tran, "noch zu verarbeiten

msgcnto TYPE apq_reco,

transcntf TYPE apq_tran, "verarbeitet

msgcntf TYPE apq_reco,

transcntd TYPE apq_tran, "gelöscht

msgcntd TYPE apq_reco,

transcnt TYPE apq_tran, "enthält aktuell

msgcnt TYPE apq_reco,

transcntx TYPE apq_tran, "entfernt

msgcntx TYPE apq_reco,

transcntp TYPE apq_tran, "angelegt

msgcntp TYPE apq_reco,

END OF apqdcnt.

DATA:

dynpro_cnt TYPE i,

show_dynpro_cnt VALUE ' ',

filename TYPE string,

lt_string TYPE char4000 OCCURS 0,

wa_string TYPE char4000,

p_cnt(8).

*----


*

*----


*

START-OF-SELECTION.

PERFORM prepare USING queue_id.

  • CALL SCREEN 100.

*----


*

*----


*

*&----


*

*& Form prepare

*&----


*

FORM prepare USING qid TYPE apqi-qid.

CLEAR: bdc_tcodes_content, bdc_dynpro_content, bdc_protocol_content.

SELECT SINGLE * FROM apqi WHERE qid = qid.

IF sy-subrc <> 0.

MESSAGE i307(00) WITH 'Lesen'(010) 'mit Queue-ID'(011) qid.

LEAVE PROGRAM.

ENDIF.

PERFORM fill_all_bdc_tcodes. " find all transactions

PERFORM get_logfiles_for_qid. " logfiles -> bdcld

PERFORM get_log USING 1. " most recent log -> bdclm

selected_protocol = 1.

GET PARAMETER ID 'RSBDC_ANALYSE_RB' FIELD rb.

IF sy-subrc <> 0.

rb-tcodes_all = 'X'. rb-pro_all = 'X'.

ENDIF.

ex_cua-fcode = 'FL_ON'. APPEND ex_cua.

ex_cua-fcode = 'FL_OFF'. APPEND ex_cua.

ENDFORM. "prepare

*----


*

  • Module loopc

*----


*

MODULE loopc OUTPUT.

loopc = sy-loopc.

ENDMODULE. "loopc OUTPUT

*----


*

  • Module status_main

*----


*

MODULE status_main OUTPUT.

CLEAR main_okcode.

SET TITLEBAR '0100' WITH apqi-groupid.

LOOP AT SCREEN.

  • set text of tabstrip tab for protocol display or set tab invisible if

  • no protocol was found for the qid

IF screen-name = 'TAB_PROTO'.

IF selected_protocol IS INITIAL.

screen-invisible = 1. MODIFY SCREEN.

ELSE.

WRITE bdcld-edate TO ex_date.

CONCATENATE '@96@' 'Protokoll vom'(020) ex_date "ICON_HISTORY

INTO tab_proto SEPARATED BY ' '.

ENDIF.

ENDIF.

ENDLOOP.

  • set header and subscreen dynpro depending on active tab

CASE tab_dynpro-activetab.

WHEN 'TAB_TCODES'.

SET PF-STATUS 'PF_MAIN' EXCLUDING ex_cua.

dynprotab_subscreen_dynpro = '0200'.

header_subscreen_dynpro = '0201'.

WHEN 'TAB_LIST'.

IF rb-fieldlist = 'X'.

SET PF-STATUS 'PF_MAIN_NAVI' EXCLUDING 'FL_ON'.

ELSE.

SET PF-STATUS 'PF_MAIN_NAVI' EXCLUDING 'FL_OFF'.

ENDIF.

dynprotab_subscreen_dynpro = '0300'.

header_subscreen_dynpro = '0301'.

WHEN 'TAB_PROTO'.

IF rb-pro_tcode = 'X'.

SET PF-STATUS 'PF_MAIN_NAVI' EXCLUDING ex_cua.

ELSE.

SET PF-STATUS 'PF_MAIN' EXCLUDING ex_cua.

ENDIF.

dynprotab_subscreen_dynpro = '0400'.

header_subscreen_dynpro = '0401'.

WHEN OTHERS.

SET PF-STATUS 'PF_MAIN' EXCLUDING ex_cua.

tab_dynpro-activetab = 'TAB_TCODES'.

dynprotab_subscreen_dynpro = '0200'.

header_subscreen_dynpro = '0201'.

ENDCASE.

  • is this the first call?

IF tcode_index IS INITIAL.

tcode_index = 1.

tcode = all_bdc_tcodes-tcode.

tcode_status = all_bdc_tcodes-s_text.

ELSE.

  • tcode_index was already set in PAI

tcode = bdc_tcodes-tcode.

tcode_status = bdc_tcodes-s_text.

ENDIF.

ENDMODULE. "status_main OUTPUT

*----


*

  • Module exit_main

*----


*

MODULE exit_main INPUT.

SET PARAMETER ID 'RSBDC_ANALYSE_RB' FIELD rb.

LEAVE PROGRAM.

ENDMODULE. "exit_main INPUT

*----


*

  • Module user_command_main

*----


*

MODULE user_command_main INPUT.

IF tab_dynpro-activetab <> 'TAB_TCODES'.

previous_tab = tab_dynpro-activetab.

ENDIF.

CASE main_okcode.

  • change the active tab

WHEN 'TAB_TCODES'.

tab_dynpro-activetab = 'TAB_TCODES'.

WHEN 'TAB_LIST'.

tab_dynpro-activetab = 'TAB_LIST'.

WHEN 'TAB_PROTO'.

tab_dynpro-activetab = 'TAB_PROTO'.

  • select entry for display

WHEN 'DISPLAY'.

PERFORM set_new_display.

  • change the viewing options

WHEN 'VIEW_OPT'.

CALL SCREEN 500 STARTING AT 5 5.

  • show list of protocols

WHEN 'PROTO'.

IF selected_protocol > 0.

CALL SCREEN 600 STARTING AT 5 5.

ELSE.

MESSAGE s324(00).

ENDIF.

WHEN 'PROTO_REFRESH'.

  • reload protocol file (while watching running sessions)

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

text = 'Protokoll wird erneut gelesen ...'(006).

PERFORM get_log USING selected_protocol.

PERFORM extend_message_texts.

CLEAR bdc_protocol_content.

  • switch field list on or off

WHEN 'FL_ON'. rb-fieldlist = 'X'.

WHEN 'FL_OFF'. rb-fieldlist = ' '.

  • go to first transaction

WHEN 'FIRST'.

IF tcode_index > 1.

READ TABLE bdc_tcodes INDEX 1.

tcode_index = 1.

PERFORM scan_transaction USING bdc_tcodes-index.

CLEAR: bdc_dynpro_content, bdc_protocol_content.

ENDIF.

  • go to next transaction

WHEN 'NEXT'.

IF tcode_index < i_tcodes.

tcode_index = tcode_index + 1.

READ TABLE bdc_tcodes INDEX tcode_index.

PERFORM scan_transaction USING bdc_tcodes-index.

CLEAR: bdc_dynpro_content, bdc_protocol_content.

ENDIF.

  • go to previous transaction

WHEN 'PREV'.

IF tcode_index > 1.

tcode_index = tcode_index - 1.

READ TABLE bdc_tcodes INDEX tcode_index.

PERFORM scan_transaction USING bdc_tcodes-index.

CLEAR: bdc_dynpro_content, bdc_protocol_content.

ENDIF.

  • go to last transaction

WHEN 'LAST'.

IF tcode_index < i_tcodes.

tcode_index = i_tcodes.

READ TABLE bdc_tcodes INDEX i_tcodes.

PERFORM scan_transaction USING bdc_tcodes-index.

CLEAR: bdc_dynpro_content, bdc_protocol_content.

ENDIF.

  • scrolling in table controls

WHEN 'P-' OR 'P--' OR 'P' OR 'P+'.

PERFORM scrolling.

  • display queue dump

WHEN 'QUEUE'.

CALL SCREEN '0700'.

  • display header (APQI)

WHEN 'APQI'.

CALL SCREEN '0701'.

  • recalculate dynpro counters

WHEN 'DISP_CNT'.

PERFORM recalculate_counters.

  • leave this nice program

WHEN 'BACK' OR 'END'.

SET PARAMETER ID 'RSBDC_ANALYSE_RB' FIELD rb.

LEAVE PROGRAM.

WHEN OTHERS.

"

ENDCASE.

  • if field list or protocol chosen, but no transaction has been

  • scanned yet, it's now time to read the first transaction from APQD

IF ( main_okcode = 'TAB_LIST' OR

main_okcode = 'TAB_PROTO' ) AND

tcode_index_apqd IS INITIAL.

READ TABLE bdc_tcodes INDEX 1.

IF sy-subrc = 0.

PERFORM scan_transaction USING bdc_tcodes-index.

tcode_index_apqd = bdc_tcodes-index.

ENDIF.

ENDIF.

ENDMODULE. "user_command_main INPUT

*----


*

  • Module fill_bdc_tcodes

  • copy transactions from all_bdc_tcodes to bdc_tcodes

  • according to rb-settings

*----


*

MODULE fill_bdc_tcodes OUTPUT.

  • check whether contents are already up to date

IF show_dynpro_cnt = 'X'.

LOOP AT SCREEN.

IF screen-group1 = 'DCT'.

screen-invisible = 0.

screen-active = 1.

MODIFY SCREEN.

ENDIF.

IF screen-name = 'CMD_DISP_CNT'.

screen-invisible = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

IF bdc_tcodes_content = 'A' AND rb-tcodes_all = 'X'.

EXIT.

ELSEIF bdc_tcodes_content = 'E' AND rb-tcodes_error = 'X'.

EXIT.

ENDIF.

  • fill bdc_tcodes according to the settings in screen 500

CLEAR bdc_tcodes. REFRESH bdc_tcodes.

IF rb-tcodes_all ='X'.

LOOP AT all_bdc_tcodes.

bdc_tcodes = all_bdc_tcodes. APPEND bdc_tcodes.

ENDLOOP.

bdc_tcodes_content = 'A'.

ELSEIF rb-tcodes_error = 'X'.

LOOP AT all_bdc_tcodes WHERE status = 'E'.

bdc_tcodes = all_bdc_tcodes. APPEND bdc_tcodes.

ENDLOOP.

bdc_tcodes_content = 'E'.

ENDIF.

DESCRIBE TABLE bdc_tcodes LINES bdc_lines.

i_tcodes = bdc_lines.

tc_tcodes-lines = bdc_lines.

CLEAR tcode_index_apqd.

READ TABLE bdc_tcodes INDEX 1.

1st_bdc_tcode_index = bdc_tcodes-index.

tcode_index = 1.

ENDMODULE. "fill_bdc_tcodes OUTPUT

*----


*

  • Module fill_bdc_dynpro

  • copy dynpro data from all_bdc_dynpro to bdc_bdc_dynpro

  • according to rb-settings

*----


*

MODULE fill_bdc_dynpro OUTPUT.

DATA: wa LIKE LINE OF tc_dynpro-cols,

tline LIKE sy-index.

tline = tc_dynpro-top_line.

tc_dynpro-top_line = tline.

  • hide fields if no detailed field list shall be displayed

LOOP AT tc_dynpro-cols INTO wa.

IF sy-tabix = 3 OR sy-tabix = 4.

IF rb-fieldlist = 'X'.

CLEAR wa-invisible.

ELSE.

wa-invisible = 1.

ENDIF.

MODIFY tc_dynpro-cols FROM wa.

ENDIF.

ENDLOOP.

  • is bdc_dynpro_content already correctly filled ?

IF rb-fieldlist = ' ' AND bdc_dynpro_content = 'S'.

EXIT.

ELSEIF rb-fieldlist = 'X' AND bdc_dynpro_content = 'F'.

EXIT.

ENDIF.

CLEAR bdc_dynpro. REFRESH bdc_dynpro.

IF rb-fieldlist = ' '.

LOOP AT all_bdc_dynpro WHERE NOT program IS INITIAL.

bdc_dynpro = all_bdc_dynpro.

APPEND bdc_dynpro.

ENDLOOP.

bdc_dynpro_content = 'S'.

ELSEIF rb-fieldlist = 'X'.

LOOP AT all_bdc_dynpro.

bdc_dynpro = all_bdc_dynpro.

APPEND bdc_dynpro.

ENDLOOP.

bdc_dynpro_content = 'F'.

ENDIF.

DESCRIBE TABLE bdc_dynpro LINES bdc_lines.

tc_dynpro-lines = bdc_lines.

tc_dynpro-top_line = 1.

ENDMODULE. "fill_bdc_dynpro OUTPUT

*----


*

  • Module fill_bdc_protocol

  • copy messages from bdclm to bdc_protocol

  • according to rb-settings

*----


*

MODULE fill_bdc_protocol OUTPUT.

IF rb-pro_all = 'X' AND bdc_protocol_content = 'A'.

EXIT.

ELSEIF rb-pro_tcode = 'X' AND bdc_protocol_content = 'T'.

EXIT.

ELSEIF rb-pro_session = 'X' AND bdc_protocol_content = 'S'.

EXIT.

ENDIF.

CLEAR bdc_protocol. REFRESH bdc_protocol.

IF rb-pro_all = 'X'.

LOOP AT bdclm.

IF rb-log_detail = ' ' AND bdclm-isdetail = 'X'.

CONTINUE.

ENDIF.

MOVE-CORRESPONDING bdclm TO bdc_protocol.

APPEND bdc_protocol.

ENDLOOP.

bdc_protocol_content = 'A'.

ELSEIF rb-pro_tcode = 'X'.

LOOP AT bdclm WHERE tcnt = tcode_index_apqd.

IF rb-log_detail = ' ' AND bdclm-isdetail = 'X'.

CONTINUE.

ENDIF.

MOVE-CORRESPONDING bdclm TO bdc_protocol.

APPEND bdc_protocol.

ENDLOOP.

bdc_protocol_content = 'T'.

ELSEIF rb-pro_session = 'X'.

LOOP AT bdclm WHERE tcnt = ' '.

MOVE-CORRESPONDING bdclm TO bdc_protocol.

APPEND bdc_protocol.

ENDLOOP.

bdc_protocol_content = 'S'.

ENDIF.

DESCRIBE TABLE bdc_protocol LINES bdc_lines.

tc_protocol-lines = bdc_lines.

tc_protocol-top_line = 1.

ENDMODULE. "fill_bdc_protocol OUTPUT

*----


*

  • Module check_bdc_tcodes

*----


*

MODULE check_bdc_protocol OUTPUT.

  • display lines intensified if they contain e- or a-messages

IF bdc_protocol-mart = 'E'

OR bdc_protocol-mart = 'A'.

LOOP AT SCREEN.

screen-intensified = 1. MODIFY SCREEN.

ENDLOOP.

ENDIF.

  • skip empty lines

IF bdc_protocol-indate IS INITIAL.

EXIT FROM STEP-LOOP.

ENDIF.

ENDMODULE. "check_bdc_protocol OUTPUT

*----


*

  • Module get_cursor_position

*----


*

MODULE get_cursor_position INPUT.

GET CURSOR FIELD c_field LINE c_line.

IF c_line > 0.

CASE tab_dynpro-activetab.

WHEN 'TAB_TCODES'.

selected_index = tc_tcodes-top_line + c_line - 1.

WHEN 'TAB_LIST'.

selected_index = tc_dynpro-top_line + c_line - 1.

WHEN 'TAB_PROTO'.

selected_index = tc_protocol-top_line + c_line - 1.

ENDCASE.

ELSE.

selected_index = 0.

ENDIF.

ENDMODULE. "get_cursor_position INPUT

*----


*

  • Module d0500_init

*----


*

MODULE d0500_init OUTPUT.

SET PF-STATUS 'POPUP'.

SET TITLEBAR '0500'.

ENDMODULE. "d0500_init OUTPUT

*----


*

  • Module d0500_fcode

*----


*

MODULE d0500_fcode INPUT.

LEAVE TO SCREEN 0.

ENDMODULE. "d0500_fcode INPUT

*----


*

  • Module d0600_init

*----


*

MODULE d0600_init OUTPUT.

SET PF-STATUS 'POPUP'.

SET TITLEBAR '0600'.

CLEAR d0600_fcode.

DESCRIBE TABLE bdcld LINES i_protocols.

tc_bdcld-lines = i_protocols.

ENDMODULE. "d0600_init OUTPUT

*----


*

  • Module d0500_fcode

  • read and process another protocol which was selected on

  • popup dynpro 500

*----


*

MODULE d0600_fcode INPUT.

CASE d0600_fcode.

WHEN 'POP_CANCEL'.

LEAVE TO SCREEN 0.

WHEN 'POP_OKAY'.

  • read selected protocol

IF tc_select <> selected_protocol.

CLEAR bdclm. REFRESH bdclm.

CLEAR bdc_protocol_content.

PERFORM get_log USING tc_select.

PERFORM extend_message_texts.

selected_protocol = tc_select.

ENDIF.

LEAVE TO SCREEN 0.

WHEN OTHERS.

  • scroll in table

ENDCASE.

ENDMODULE. "d0600_fcode INPUT

*----


*

  • Module set_mark

  • set table view marker for the actual selected protocol

  • (dynpro 500)

*----


*

MODULE set_mark OUTPUT.

tc_index = tc_bdcld-top_line + tc_bdcld-current_line - 1.

IF tc_index = selected_protocol.

tc_mark = 'X'.

ENDIF.

ENDMODULE. "set_mark OUTPUT

*----


*

  • Module get_mark

  • get index of selected protocol on popup 500

*----


*

MODULE get_mark INPUT.

IF tc_mark = 'X'.

tc_select = tc_bdcld-top_line + tc_bdcld-current_line - 1.

ENDIF.

ENDMODULE. "get_mark INPUT

*----


*

  • FORM: fill_bdc_tcodes

  • Read all transaction codes from apqd and fill internal table

*----


*

FORM fill_all_bdc_tcodes.

  • read APQD blocks 1 for QID

CLEAR all_bdc_tcodes. REFRESH all_bdc_tcodes.

SELECT * FROM apqd WHERE qid = queue_id AND block = 1

ORDER BY PRIMARY KEY.

MOVE apqd-vardata TO bdcth.

all_bdc_tcodes-index = apqd-trans.

all_bdc_tcodes-tcode = bdcth-tcode.

all_bdc_tcodes-status = bdcth-state.

APPEND all_bdc_tcodes.

ENDSELECT.

  • convert status flag to long text

  • calculate transaction counters

CLEAR apqdcnt.

LOOP AT all_bdc_tcodes.

ADD 1 TO apqdcnt-transcnt.

CASE all_bdc_tcodes-status.

WHEN 'D' OR 'G'.

all_bdc_tcodes-s_text = 'gelöscht'(005).

ADD 1 TO apqdcnt-transcntd.

WHEN 'F'.

all_bdc_tcodes-s_text = 'verarbeitet'(002).

ADD 1 TO apqdcnt-transcntf.

WHEN 'E'.

all_bdc_tcodes-s_text = 'fehlerhaft'(001).

ADD 1 TO apqdcnt-transcnte.

WHEN 'B'.

all_bdc_tcodes-s_text = ' '. "neu

ADD 1 TO apqdcnt-transcntb.

WHEN OTHERS.

all_bdc_tcodes-s_text = ' '.

ENDCASE.

MODIFY all_bdc_tcodes.

ENDLOOP.

apqdcnt-transcnto = apqdcnt-transcntb

+ apqdcnt-transcnte.

apqdcnt-transcntd = apqdcnt-transcnt

- apqdcnt-transcntf

- apqdcnt-transcnte

- apqdcnt-transcntb.

apqdcnt-transcntp = apqi-puttrans.

apqdcnt-transcntx = apqdcnt-transcntp

- apqdcnt-transcnt.

IF apqi-msgcnt < 1000.

PERFORM recalculate_counters.

ENDIF.

ENDFORM. "fill_all_bdc_tcodes

*----


*

  • FORM scan_transaction

  • Read all APQD data for a selected transaction

*----


*

FORM scan_transaction USING tcnt.

CLEAR it_apqd. REFRESH it_apqd.

CLEAR all_bdc_dynpro. REFRESH all_bdc_dynpro.

SELECT * FROM apqd INTO TABLE it_apqd

WHERE qid = queue_id AND trans = tcnt.

tcode_index_apqd = tcnt. "Display correct index in header screens

CLEAR dynpro_index.

LOOP AT it_apqd.

IF it_apqd-vardata(1) = 'M'. "it's a message header

dynpro_index = dynpro_index + 1.

PERFORM scan_dynpro.

ENDIF.

ENDLOOP.

ENDFORM. "scan_transaction

*----


*

  • FORM: scan_dynpro

  • Scan APQD data for a single dynpro screen

  • and put it into a BDCDATA table

*----


*

FORM scan_dynpro.

*

MOVE it_apqd-vardata TO bdcmh.

TRANSLATE bdcmh TO UPPER CASE.

  • get program name and screen number

CLEAR all_bdc_dynpro.

all_bdc_dynpro-index = dynpro_index.

all_bdc_dynpro-program = bdcmh-prog.

all_bdc_dynpro-dynpro = bdcmh-dynr.

APPEND all_bdc_dynpro.

  • get all the fnam/fval pairs

MOVE it_apqd-vardata TO sdat.

SHIFT sdat BY bdcmhlen PLACES.

wcount = bdcmhlen.

mfstart = wcount.

mfart = 'FN'.

WHILE wcount LE it_apqd-varlen.

IF sdat(1) = bdcmh-sepc.

mfende = wcount.

PERFORM move_tf.

ENDIF.

SHIFT sdat.

wcount = wcount + 1.

ENDWHILE.

ENDFORM. "scan_dynpro

*----


*

  • Parse the apqd-vardata field for FNAM/FVAL pairs

  • FORM: move_tf

  • fills TF-FNAME and TF-FARG

*----


*

FORM move_tf.

mflen = mfende - mfstart.

CASE mfart.

WHEN 'FN'.

CLEAR: tf-fname, udat.

tf-fstart = mfstart.

MOVE it_apqd-vardata TO udat.

SHIFT udat BY mfstart PLACES.

WRITE udat TO tf-fname+0(mflen).

TRANSLATE tf-fname TO UPPER CASE.

mfstart = mfende + 1.

mfende = 0.

MOVE 'FA' TO mfart.

WHEN 'FA'.

CLEAR: tf-farg, udat.

tf-fende = mfende.

MOVE it_apqd-vardata TO udat.

SHIFT udat BY mfstart PLACES.

WRITE udat TO tf-farg+0(mflen).

APPEND tf.

tf-stat = space.

mfstart = mfende + 1.

mfende = 0.

MOVE 'FN' TO mfart.

  • copy to bdcdata table if fname/fval is not empty

CHECK NOT tf-fname IS INITIAL.

  • CHECK NOT TF-FARG IS INITIAL.

CLEAR all_bdc_dynpro.

all_bdc_dynpro-index = dynpro_index.

all_bdc_dynpro-fnam = tf-fname.

all_bdc_dynpro-fval = tf-farg.

APPEND all_bdc_dynpro.

WHEN OTHERS.

ENDCASE.

ENDFORM. "move_tf

*----


*

  • Form: get_logfiles_for_qid

*----


*

DATA:

paramname(11) VALUE 'bdc/logfile',

logname(80),

logname1(80),

old_logfile(06) VALUE 'bdclog',

new_logfile(04) VALUE 'BI* ',

shiftlen TYPE i VALUE 0,

protflen TYPE i VALUE 0,

protfoff TYPE i VALUE 0,

rlen TYPE i VALUE 0,

bdcld# TYPE i, one TYPE i, ec TYPE i, return TYPE i,

protcnt TYPE i.

DATA:

BEGIN OF prot_list OCCURS 0.

INCLUDE rstr0112.

DATA: seen(1), to_be_deleted(1), has_changed(1), local_host(24),

END OF prot_list.

DATA:

BEGIN OF file.

INCLUDE rstr0112.

DATA END OF file.

DATA:

BEGIN OF bdclda OCCURS 0.

INCLUDE STRUCTURE bdcld.

DATA END OF bdclda .

DATA:

digits(10) TYPE c VALUE '0123456789',

mtext(124) TYPE c, "Messagetext

mtext1(124) TYPE c, "Messagetext

mtext2(273) TYPE c, "Messagetext

do_condense TYPE c,

mtvaroff TYPE i,

showtyp(05) TYPE c, "showtyp

lmapn(12) TYPE c, "Hilfsfeld log-mapn

date1 TYPE d,

linct0 LIKE sy-linct,

parcnt TYPE i,

sp_len TYPE i,

charcnt TYPE i,

wcnt TYPE i,

mparcnt TYPE i,

qfound(04) TYPE n,

x(1) VALUE 'X'.

DATA: "Aufbereitung Messagetext

BEGIN OF mt,

off(02) TYPE n,

len(02) TYPE n,

text(80),

END OF mt.

DATA: "Aufbereitung Messagetext

BEGIN OF mttab OCCURS 4,

off(02) TYPE n,

len(02) TYPE n,

text(80),

END OF mttab.

DATA: "Hilfsfelder

BEGIN OF old,

tcnt LIKE bdclm-tcnt,

mcnt LIKE bdclm-mcnt,

END OF old.

DATA: "ParameterAufbereitung

BEGIN OF par,

len(02) TYPE n,

text(254),

END OF par.

*----


*

  • Form get_logfiles_for_qid

  • find all log files for the session in analysis,

  • either in common log or in TemSe

*----


*

FORM get_logfiles_for_qid.

  • get logs from TemSe

PERFORM get_logfiles_from_temse.

  • now bdcld contains the log files for the given qid

SORT bdcld BY edate DESCENDING etime DESCENDING.

DESCRIBE TABLE bdcld LINES selected_protocol.

ENDFORM. "get_logfiles_for_qid

*----


*

  • Form: log_dir

*----


*

FORM log_dir.

*

CLEAR bdclda. REFRESH bdclda.

CALL 'ReadLogDirA' ID 'LOGN' FIELD logname

ID 'DTAB' FIELD bdclda-sys

ID 'AINF' FIELD one

ID 'ECNT' FIELD ec.

*

IF sy-subrc NE 0 OR ec = 0.

EXIT.

ENDIF.

LOOP AT bdclda WHERE lmand = sy-mandt AND quid = queue_id.

MOVE-CORRESPONDING bdclda TO bdcld.

MOVE logname TO bdcld-logname.

MOVE prot_list-local_host TO bdcld-local_host.

APPEND bdcld.

ENDLOOP.

ENDFORM. " log_dir.

*----


*

  • Form: list_protocol_files

  • Suche nach allen aktiven Protokolldateien -> Tabelle prot_list

*----


*

FORM list_protocol_files.

CLEAR: logname1, prot_list, protcnt.

REFRESH: prot_list.

protflen = STRLEN( logname ).

MOVE logname TO logname1.

WHILE shiftlen LE protflen.

IF logname1 CP '#B#I'. "suchen nach muster #B#I

IF sy-fdpos EQ 0. "nur großbuchstaben

shiftlen = 2.

ELSE.

shiftlen = sy-fdpos.

ENDIF.

protfoff = protfoff + shiftlen.

SHIFT logname1 BY shiftlen PLACES.

ELSE.

shiftlen = protflen + 1.

protfoff = protfoff - 2.

ENDIF.

ENDWHILE.

*

IF protfoff LE 0.

protfoff = 0.

ENDIF.

*

rlen = 80 - protfoff.

*

WRITE space TO logname+protfoff(rlen).

WRITE new_logfile TO logname+protfoff(4).

*

PERFORM search_prot USING logname.

ENDFORM. " FILL_PROT_LIST

*

*----


*

  • FORM : search_prot *

*----


*

FORM search_prot USING prot_files.

*

DATA: errcnt(2) TYPE p VALUE 0.

*

CALL 'C_DIR_READ_START' ID 'FILE' FIELD prot_files

ID 'ERRNO' FIELD file-errno

ID 'ERRMSG' FIELD file-errmsg.

IF sy-subrc <> 0.

MESSAGE i398(00)

WITH sy-subrc 'C_DIR_READ_START' ' ' prot_files.

MESSAGE i398(00)

WITH sy-subrc 'C_DIR_READ_START...'

file-errno file-errmsg.

ENDIF.

DO. "aufbau der internen tabelle fuer alle

"BI-Protokolle

CLEAR file.

CALL 'C_DIR_READ_NEXT'

ID 'TYPE' FIELD file-type

ID 'NAME' FIELD file-name

ID 'LEN' FIELD file-len

ID 'OWNER' FIELD file-owner

ID 'MTIME' FIELD file-mtime

ID 'MODE' FIELD file-mode

ID 'ERRNO' FIELD file-errno

ID 'ERRMSG' FIELD file-errmsg.

MOVE sy-subrc TO file-subrc.

CASE sy-subrc.

WHEN 0.

CASE file-type(1).

WHEN 'F'. " normal file.

MOVE 1 TO file-useable.

WHEN 'f'. " normal file.

MOVE 1 TO file-useable.

WHEN OTHERS. " Directory, device, fifo, socket,...

MOVE 0 TO file-useable.

ENDCASE.

IF file-len = 0.

MOVE 0 TO file-useable.

ENDIF.

WHEN 1.

EXIT.

WHEN OTHERS. " SY-SUBRC >= 2

ADD 1 TO errcnt.

IF errcnt > 10.

EXIT.

ENDIF.

IF sy-subrc = 5.

MOVE: '???' TO file-type,

'???' TO file-owner,

'???' TO file-mode.

ELSE.

ENDIF.

file-useable = 0.

ENDCASE.

MOVE-CORRESPONDING file TO prot_list.

SHIFT file-name BY protfoff PLACES.

prot_list-local_host = file-name.

protcnt = protcnt + 1.

APPEND prot_list.

ENDDO.

CALL 'C_DIR_READ_FINISH'

ID 'ERRNO' FIELD file-errno

ID 'ERRMSG' FIELD file-errmsg.

IF sy-subrc <> 0.

  • WRITE: / 'C_DIR_READ_FINISH'(999), 'SUBRC', SY-SUBRC.

ENDIF.

ENDFORM. " search_prot

*----


*

  • Form: get_log

*----


*

FORM get_log USING log_index.

DATA: BEGIN OF logtable OCCURS 50, " plain log information in TemSe

enterdate LIKE btctle-enterdate,

entertime LIKE btctle-entertime,

logmessage(400) TYPE c,

END OF logtable.

DATA:

external_date(10),

internal_date TYPE d.

LOOP AT bdcld.

logname = bdcld-logname.

IF newprot = 'OFF'.

  • get logfile contents from common log file

CALL 'ReadLogPartitionA' ID 'LOGN' FIELD logname

ID 'ETAB' FIELD bdclm-sys

ID 'PART' FIELD bdcld

ID 'ECNT' FIELD ec.

IF sy-subrc <> 0. MESSAGE s325(00). ENDIF.

IF ec = 0. MESSAGE s324(00). ENDIF.

ELSE.

  • get logfile contents from TemSe

PERFORM read_bdc_log_plain

TABLES logtable

USING bdcld-temseid bdcld-lmand.

IF sy-subrc <> 0. " Fehler beim Lesen

MESSAGE s004(ts).

EXIT.

ENDIF.

CLEAR bdclm[].

LOOP AT logtable.

*----


*

  • Es wird geprüft, ob von TEMSE das Datum korrekt geliefert wurde

  • wenn nicht wird einfach der Satz ignoriert und nicht gelesen

*----


*

CALL 'DATE_CONV_INT_TO_EXT'

ID 'DATINT' FIELD logtable-enterdate

ID 'DATEXT' FIELD external_date.

CALL 'DATE_CONV_EXT_TO_INT'

ID 'DATEXT' FIELD external_date

ID 'DATINT' FIELD internal_date.

IF sy-subrc NE 0. " Datum ist nicht gültig

CONTINUE.

ENDIF.

CLEAR bdclm.

bdclm-indate = logtable-enterdate.

bdclm-intime = logtable-entertime.

bdclm+14(352) = logtable-logmessage.

IF bdclm-mcnt > 0.

bdclm-mcnt = bdclm-mcnt - 1.

ENDIF.

IF bdclm-mid EQ '00'.

IF ( bdclm-mnr EQ '162' )

OR ( bdclm-mnr EQ '368' ).

bdclm-isdetail = 'X'.

ENDIF.

ENDIF.

APPEND bdclm.

ENDLOOP.

PERFORM extend_message_texts. " extended texts -> bdclm

PERFORM download.

ENDIF.

ENDLOOP.

ENDFORM. "get_log

*----


*

  • Form: get_logfiles_from_temse

*----


*

FORM get_logfiles_from_temse.

  • are there any logs in the TemSe for this QID ?

CLEAR logtab_temse[].

CLEAR bdcld[].

SELECT * FROM apql INTO TABLE logtab_temse

WHERE qid = apqi-qid.

CHECK sy-subrc = 0.

  • some logs were found: now put this info into table bdcld.

DATA: wa_log LIKE LINE OF logtab_temse,

wa_ld LIKE LINE OF bdcld.

LOOP AT logtab_temse INTO wa_log.

CLEAR wa_ld.

wa_ld-temseid = wa_log-temseid.

wa_ld-lmand = wa_log-mandant.

wa_ld-edate = wa_log-credate.

wa_ld-etime = wa_log-cretime.

wa_ld-luser = wa_log-creator.

wa_ld-grpn = wa_log-groupid.

wa_ld-quid = wa_log-qid.

wa_ld-local_host = wa_log-destsys(8).

APPEND wa_ld TO bdcld.

ENDLOOP.

ENDFORM. "get_logfiles_from_temse

*----


*

  • Form: extend_message_texts

*----


*

FORM extend_message_texts.

LOOP AT bdclm.

lm = bdclm. save_mpar = bdclm-mpar.

PERFORM get_text.

bdclm-longtext = mtext.

bdclm-mpar = save_mpar.

MODIFY bdclm.

ENDLOOP.

ENDFORM. "extend_message_texts

*----


*

  • FORM : get_text *

*----


*

FORM get_text.

*

      • Aufbereiten des Messagetextes

*

DATA: shiftln TYPE i,

vartcnt TYPE i,

fdpos LIKE sy-fdpos.

IF bdclm-mparcnt CN digits. "Korrupter Datensatz:

bdclm-mparcnt = 0. "z.B. Hexnullen

ENDIF.

SELECT SINGLE * FROM t100

WHERE sprsl = sy-langu

AND arbgb = bdclm-mid

AND msgnr = bdclm-mnr.

*

IF sy-subrc EQ 0.

CLEAR: mtext,

parcnt,

mparcnt,

charcnt,

wcnt,

mt,

sp_len,

sy-fdpos.

*

MOVE bdclm-mparcnt TO mparcnt.

*

IF t100-text CA '$&'. "Kennung fuer parameter:

MOVE t100-text TO mtext1. " alt '$' --- neu '&'

ELSE.

MOVE t100-text TO mtext.

EXIT.

ENDIF.

  • variable teile aus batch-input protokoll in mttab bringen.

REFRESH mttab.

CLEAR shiftln.

DO mparcnt TIMES.

CLEAR: par, mttab.

MOVE bdclm-mpar TO par.

IF par-len CN digits OR par-len EQ 0. "convert_no_number

par-len = 1. "entschärfen

par-text = ' '.

shiftln = 2.

ELSE.

shiftln = par-len + 2.

ENDIF.

WRITE par-text TO mttab-text(par-len).

MOVE par-len TO mttab-len.

MOVE mparcnt TO mttab-off.

APPEND mttab.

SHIFT bdclm-mpar BY shiftln PLACES.

ENDDO.

*

mtext2 = mtext1.

IF bdclm-mid EQ '00' AND " sonderbehandlung s00368

bdclm-mnr EQ '368' AND

bdclm-mart EQ 'S'.

CLEAR mtext2.

CLEAR mttab.

READ TABLE mttab INDEX 1.

WRITE mttab-text TO mtext2+0(mttab-len).

CLEAR mttab.

READ TABLE mttab INDEX 2.

WRITE mttab-text TO mtext2+35(mttab-len).

mtext = mtext2.

EXIT.

ENDIF.

do_condense = x.

CLEAR: mt, vartcnt, mtvaroff.

WHILE vartcnt LE 3.

vartcnt = vartcnt + 1.

IF mtext1 CA '$&'.

parcnt = parcnt + 1.

IF sy-fdpos GT 0.

fdpos = sy-fdpos - 1. " neu sy-fdpos -1

ELSE.

fdpos = sy-fdpos.

ENDIF.

SHIFT mtext1 BY sy-fdpos PLACES.

IF mtext1(1) EQ '&'.

SHIFT mtext1 BY 1 PLACES.

CASE mtext1(1).

WHEN ' '. "'& '

PERFORM replace_var USING '& ' parcnt fdpos.

WHEN '$'. "'&&'

PERFORM replace_var USING '&&' 0 fdpos.

WHEN '1'. "'&1'

PERFORM replace_var USING '&1' 1 fdpos.

WHEN '2'. "'&2'

PERFORM replace_var USING '&2' 2 fdpos.

WHEN '3'. "'&3'

PERFORM replace_var USING '&3' 3 fdpos.

WHEN '4'. "'&4'

PERFORM replace_var USING '&4' 4 fdpos.

WHEN OTHERS. "'&'

PERFORM replace_var USING '&<' parcnt fdpos.

ENDCASE.

ENDIF.

IF mtext1(1) EQ '$'.

SHIFT mtext1 BY 1 PLACES.

CASE mtext1(1).

WHEN ' '. "'$ '

PERFORM replace_var USING '$ ' parcnt fdpos.

WHEN '$'. "'$$'

PERFORM replace_var USING '$$' 0 fdpos.

WHEN '1'. "'$1'

PERFORM replace_var USING '$1' 1 fdpos.

WHEN '2'. "'$2'

PERFORM replace_var USING '$2' 2 fdpos.

WHEN '3'. "'$3'

PERFORM replace_var USING '$3' 3 fdpos.

WHEN '4'. "'$4'

PERFORM replace_var USING '$4' 4 fdpos.

WHEN OTHERS. "'$'

PERFORM replace_var USING '$<' parcnt fdpos.

ENDCASE.

ENDIF.

ENDIF.

ENDWHILE.

*

IF mtext2 CA '%%_D_%%'.

REPLACE '%%_D_%%' WITH '$' INTO mtext2.

ENDIF.

IF mtext2 CA '%%_A_%%'.

REPLACE '%%_A_%%' WITH '&' INTO mtext2.

ENDIF.

IF do_condense EQ space.

mtext = mtext2.

ELSE.

CONDENSE mtext2 .

mtext = mtext2.

ENDIF.

ELSE.

mtext = '???????????????????????????????????????????????????'.

ENDIF.

*

ENDFORM. " get_text1

*----


*

  • FORM : replace_var *

  • *

*----


*

FORM replace_var USING vark vari varpos.

*

  • ersetzen der variablen teile einer fehlermeldung

*

DATA: var(02),

var1,

moff TYPE i.

*

CLEAR: mttab , moff.

var = vark.

SHIFT var BY 1 PLACES.

CASE var.

WHEN ' '. "'& '

READ TABLE mttab INDEX vari.

IF sy-subrc EQ 0.

moff = varpos + mtvaroff.

ASSIGN mtext2+moff(*) TO . "neu

mtvaroff = 7. "neu

ENDIF.

ENDIF.

*

ENDCASE.

*

do_condense = space.

*

ENDFORM. "replace_var

*----


*

  • Form: set_new_display

*----


*

FORM set_new_display.

CASE tab_dynpro-activetab.

WHEN 'TAB_TCODES'.

  • F2 in tcodes list: choose new transaction:

CHECK selected_index > 0.

READ TABLE bdc_tcodes INDEX selected_index.

CHECK sy-subrc = 0.

PERFORM scan_transaction USING bdc_tcodes-index.

CLEAR: bdc_dynpro_content, bdc_protocol_content.

tcode_index = selected_index.

tcode_status = bdc_tcodes-s_text.

tcode = bdc_tcodes-tcode.

IF previous_tab IS INITIAL.

tab_dynpro-activetab = 'TAB_LIST'.

ELSE.

tab_dynpro-activetab = previous_tab.

ENDIF.

WHEN 'TAB_LIST'.

  • F2 in screens list: simulate screen

CHECK selected_index > 0.

  • simulate screen

PERFORM simulate_dynpro.

WHEN 'TAB_PROTO'.

  • F2 in protocol list: show message long text:

CHECK selected_index > 0.

READ TABLE bdc_protocol INDEX selected_index.

CHECK sy-subrc = 0.

PERFORM show_ltext.

ENDCASE.

ENDFORM. "set_new_display

*----


*

  • FORM : show_ltext

  • display long text for a log message

*----


*

FORM show_ltext.

*

DATA:

docnt TYPE i.

DATA:

BEGIN OF my,

msgv1 LIKE sy-msgv1,

msgv2 LIKE sy-msgv2,

msgv3 LIKE sy-msgv3,

msgv4 LIKE sy-msgv4,

END OF my.

DATA:

msg_text LIKE shkontext-meldung,

msg_arbgb LIKE shkontext-meld_id,

msg_nr LIKE shkontext-meld_nr,

msg_title LIKE shkontext-titel.

*

  • RABAX- or T100 message ?

*

IF bdc_protocol-mid EQ '00' AND "Rabax

bdc_protocol-mnr EQ '341'.

CLEAR: par.

  • extract Rabax-ID and key fields from message string

par = bdc_protocol-mpar.

IF par-len CN digits. EXIT. ENDIF. "corrupt string"

my-msgv1 = par-text(par-len).

SHIFT par LEFT BY par-len PLACES.

SHIFT par LEFT BY 2 PLACES.

IF par-len CN digits. EXIT. ENDIF. "corrupt string"

snap = par-text(par-len).

  • Rabax display

CALL DIALOG 'RS_RUN_TIME_ERROR'

EXPORTING

snap-mandt

snap-datum

snap-uzeit

snap-ahost

snap-uname

snap-modno.

EXIT.

ENDIF.

*

  • no RABAX

*

docnt = 0.

*

CLEAR: my.

IF bdc_protocol-mparcnt CN digits. "Korrupter Datensatz:

bdc_protocol-mparcnt = 0. "z.B. Hexnullen

ENDIF.

DO bdc_protocol-mparcnt TIMES.

IF bdc_protocol-mpar(1) EQ space.

EXIT.

ENDIF.

docnt = docnt + 1.

CLEAR par.

MOVE bdc_protocol-mpar TO par.

*

IF par-len CN digits. "convert_no_number

par-len = 1. "entschärfen

ENDIF.

*

CASE docnt.

WHEN 1.

WRITE par-text TO my-msgv1(par-len).

WHEN 2.

WRITE par-text TO my-msgv2(par-len).

WHEN 3.

WRITE par-text TO my-msgv3(par-len).

WHEN 4.

WRITE par-text TO my-msgv4(par-len).

ENDCASE.

par-len = par-len + 2.

SHIFT bdc_protocol-mpar BY par-len PLACES.

ENDDO.

msg_arbgb = bdc_protocol-mid.

msg_nr = bdc_protocol-mnr.

msg_text = mtext.

msg_title = sy-title.

CALL FUNCTION 'HELPSCREEN_NA_CREATE'

EXPORTING

meldung = msg_text

meld_id = msg_arbgb

meld_nr = msg_nr

msgv1 = my-msgv1

msgv2 = my-msgv2

msgv3 = my-msgv3

msgv4 = my-msgv4

titel = msg_title.

ENDFORM. " show_ltext.

*----


*

  • FORM: simulate_dynpro

  • use function module CAT_SIMULATE_DYNPRO to simulate a dynpro

  • with contents according to APQD data of session

*----


*

FORM simulate_dynpro.

DATA:

cat_okcode LIKE sy-ucomm,

cat_params LIKE catp OCCURS 0 WITH HEADER LINE,

on_subscreen.

CLEAR cat_bdcdata. REFRESH cat_bdcdata.

READ TABLE bdc_dynpro INDEX selected_index.

LOOP AT all_bdc_dynpro WHERE index = bdc_dynpro-index.

MOVE-CORRESPONDING all_bdc_dynpro TO cat_bdcdata.

APPEND cat_bdcdata.

ENDLOOP.

READ TABLE cat_bdcdata INDEX 1.

cat_bdcdata-dynbegin = 'X'. MODIFY cat_bdcdata INDEX 1.

  • now we need some extra work to generate the correct input data

  • format for FUNCTION 'CAT_SIMULATE_DYNPRO' for subscreen fields.

CLEAR on_subscreen.

LOOP AT cat_bdcdata.

  • check if there is a new subscreen

IF cat_bdcdata-fnam = 'BDC_SUBSCR'.

MOVE cat_bdcdata-fval TO bdc_subscreen.

CLEAR cat_bdcdata-fval.

CONCATENATE bdc_subscreen-program

bdc_subscreen-dynpro

bdc_subscreen-subscr

INTO cat_bdcdata-fval SEPARATED BY ' '.

MODIFY cat_bdcdata.

on_subscreen = 'X'.

ENDIF.

ENDLOOP.

READ TABLE cat_bdcdata INDEX 1.

SET PF-STATUS 'CSIM'.

SET TITLEBAR '0300' WITH cat_bdcdata-program cat_bdcdata-dynpro.

MESSAGE s223(tt).

CALL FUNCTION 'CAT_SIMULATE_DYNPRO'

EXPORTING

mpool = cat_bdcdata-program

dynnr = cat_bdcdata-dynpro

display_only = 'X'

own_status_title = 'X'

TABLES

fielddata = cat_bdcdata

paramlist = cat_params

EXCEPTIONS

no_dynpro = 1

dynpro_not_found = 2

gen_error = 3

enq_error = 4

subscr_error = 5

OTHERS = 6.

CASE sy-subrc.

WHEN 1. MESSAGE s221(tt).

WHEN 2.

MESSAGE s219(tt)

WITH cat_bdcdata-program cat_bdcdata-dynpro.

WHEN 3. MESSAGE s236(tt) WITH ' ' ' '.

WHEN 4. MESSAGE s215(tt).

WHEN 5. MESSAGE s238(tt) WITH ' ' ' '.

WHEN 6. MESSAGE s258(00).

ENDCASE.

ENDFORM. "simulate_dynpro

*----


*

  • Form: scrolling

  • scrolling in table controls according to SAP style guide

*----


*

FORM scrolling.

DATA:

top_line LIKE sy-index,

last_line LIKE sy-index.

CASE tab_dynpro-activetab.

WHEN 'TAB_TCODES'.

top_line = tc_tcodes-top_line.

DESCRIBE TABLE bdc_tcodes LINES last_line.

WHEN 'TAB_LIST'.

top_line = tc_dynpro-top_line.

DESCRIBE TABLE bdc_dynpro LINES last_line.

WHEN 'TAB_PROTO'.

top_line = tc_protocol-top_line.

DESCRIBE TABLE bdc_protocol LINES last_line.

ENDCASE.

CALL FUNCTION 'SCROLLING_IN_TABLE'

EXPORTING

entry_act = top_line

entry_from = 1

entry_to = last_line

ok_code = main_okcode

last_page_full = ' '

overlapping = ' '

loops = loopc

IMPORTING

entries_sum = entries

entry_new = new_line

pages_sum = total_pages

page_new = new_page

EXCEPTIONS

no_entry_or_page_act = 01

no_entry_to = 02

no_ok_code_or_page_go = 03.

CHECK sy-subrc = 0.

CASE tab_dynpro-activetab.

WHEN 'TAB_TCODES'.

tc_tcodes-top_line = new_line.

WHEN 'TAB_LIST'.

tc_dynpro-top_line = new_line.

WHEN 'TAB_PROTO'.

tc_protocol-top_line = new_line.

ENDCASE.

ENDFORM. "scrolling

*&----


*

*& Module d0700_init OUTPUT

*&----


*

MODULE d0700_init OUTPUT.

CLEAR d0700_fcode.

SET TITLEBAR 'QUEUE_DUMP' WITH apqi-groupid.

SET PF-STATUS 'PF_QUEUE'.

IF q-tcode_index IS INITIAL.

IF NOT tcode_index_apqd IS INITIAL.

q-tcode_index = tcode_index_apqd.

ELSE.

READ TABLE all_bdc_tcodes INTO q-wa INDEX 1.

q-tcode_index = q-wa-index.

ENDIF.

ENDIF.

  • check for unicode; how many byte's a character?

DESCRIBE FIELD q-c LENGTH q-uc_bytes IN BYTE MODE.

  • read all blocks (dynpros) of the currently selected transaction

SELECT * FROM apqd INTO TABLE it_apqd

WHERE qid = queue_id AND trans = q-tcode_index.

ENDMODULE. " d0700_init OUTPUT

*&----


*

*& Module d0700_fcode INPUT

*&----


*

MODULE d0700_fcode INPUT.

CASE d0700_fcode.

WHEN 'BACK'.

CLEAR q-tcode_index.

LEAVE TO SCREEN 0.

WHEN 'END'.

CLEAR q-tcode_index.

LEAVE PROGRAM.

WHEN 'TOGGLE'.

IF q-show_hex IS INITIAL.

q-show_hex = 'X'.

ELSE.

CLEAR q-show_hex.

ENDIF.

WHEN 'APQI'.

CALL SCREEN '0701'.

WHEN OTHERS.

"nop

ENDCASE.

ENDMODULE. " ok_700 INPUT

*&----


*

*& Module exit_700 INPUT

*&----


*

MODULE d0700_exit INPUT.

LEAVE TO SCREEN 0.

ENDMODULE. " exit_700 INPUT

*&----


*

*& Module set_status_icon OUTPUT

*&----


*

MODULE set_status_icon OUTPUT.

DATA: icon_name(4),

icon_info(32).

CASE all_bdc_tcodes-status.

WHEN 'F'.

icon_name = icon_status_ok.

icon_info = 'verarbeitet'(002).

WHEN 'E'.

icon_name = icon_status_critical.

icon_info = 'fehlerhaft'(001).

WHEN 'D'.

icon_name = icon_delete.

icon_info = 'gelöscht'(005).

WHEN ' ' OR 'B'.

icon_name = icon_create.

icon_info = 'neu'(034).

WHEN OTHERS.

icon_name = all_bdc_tcodes-status.

icon_info = '???'.

ENDCASE.

CALL FUNCTION 'ICON_CREATE'

EXPORTING

name = icon_name

info = icon_info

IMPORTING

RESULT = status_icon

EXCEPTIONS

OTHERS = 1.

IF sy-subrc <> 0.

status_icon = icon_name.

ENDIF.

IF all_bdc_tcodes-index = q-tcode_index.

LOOP AT SCREEN.

screen-intensified = 1.

MODIFY SCREEN.

ENDLOOP.

ENDIF.

ENDMODULE. " set_status_icon OUTPUT

*&----


*

*& Module d0700_get_cursor INPUT

*&----


*

MODULE d0700_get_cursor INPUT.

GET CURSOR FIELD q-c_field LINE q-c_line AREA q-c_area.

IF sy-subrc = 0.

CHECK q-c_area = 'TC_Q_TCODES'.

CHECK q-c_line > 0.

q-itab_index = tc_q_tcodes-top_line + q-c_line - 1.

READ TABLE all_bdc_tcodes INTO q-wa INDEX q-itab_index.

q-tcode_index = q-wa-index.

ENDIF.

ENDMODULE. " d0700_get_cursor INPUT

*&----


*

*& Module d0700_control_init OUTPUT

*&----


*

MODULE d0700_control_init OUTPUT.

CHECK q-control_init = 'X'.

  • create custom container and dynamic document

CREATE OBJECT cust

EXPORTING

container_name = 'CUSTOM_CONTAINER'

dynnr = '0700'

repid = 'RSBDC_ANALYSE'

  • lifetime = cntl_lifetime_dynpro

EXCEPTIONS

OTHERS = 1.

CREATE OBJECT dd

EXPORTING

background_color = cl_dd_area=>col_textarea.

CLEAR q-control_init.

ENDMODULE. " d0700_control_init OUTPUT

*&----


*

*& Module d0700_display OUTPUT

*&----


*

MODULE d0700_display OUTPUT.

CALL METHOD dd->initialize_document

EXPORTING

background_color = cl_dd_area=>col_textarea.

REFRESH it_blocks.

  • loop at all apqd blocks for the current transaction and built up the

  • dynamic document for each block

LOOP AT it_apqd.

PERFORM build_queue_dd.

ENDLOOP.

CALL METHOD dd->merge_document.

CALL METHOD dd->display_document

EXPORTING

parent = cust

reuse_control = q-reuse_control

EXCEPTIONS

html_display_error = 1.

  • if the HTML control for the DD is already created, we can re-use it.

IF q-reuse_control IS INITIAL.

q-reuse_control = 'X'.

ENDIF.

ENDMODULE. " d0700_display OUTPUT

*&----


*

*& Form build_queue_dd

*&----


*

FORM build_queue_dd.

DATA: off LIKE sy-index.

  • write the most important apqd header fields

dd->new_line( ).

WRITE it_apqd-qid TO c.

CONCATENATE 'Queue-ID:'(030) c INTO t SEPARATED BY space.

dd->add_text( text = t ).

dd->new_line( ).

WRITE it_apqd-trans TO c.

CONCATENATE 'Transaktion:'(031) c INTO t SEPARATED BY space.

dd->add_text( text = t ).

dd->new_line( ).

WRITE it_apqd-block TO c.

CONCATENATE 'Block:'(032) c INTO t SEPARATED BY space.

dd->add_text( text = t

sap_color = cl_dd_table_area=>list_positive ).

dd->new_line( ).

WRITE it_apqd-varlen TO c.

CONCATENATE 'VARDATA-Länge:'(033) c INTO t SEPARATED BY space.

dd->add_text( text = t ).

dd->new_line( ).

  • now add a DD table to it_blocks for the current APQD block

CLEAR b_wa.

REFRESH it_cx.

CALL METHOD dd->add_table

EXPORTING

no_of_columns = nr_cols

cell_background_transparent = space

border = '0'

width = '100%'

IMPORTING

tablearea = b_wa-dta

table = b_wa-dt

EXCEPTIONS

OTHERS = 1.

APPEND b_wa TO it_blocks.

  • prepare ascii/hex table

DO it_apqd-varlen TIMES.

off = sy-index - 1.

ASSIGN it_apqd-vardata+off(1) TO .

WRITE cx-hex TO cx-xtoc.

APPEND cx TO it_cx.

ENDDO.

  • write apqd-vardata (as prepared in it_cx ) to the DD list

PERFORM vardata_lines.

ENDFORM. " build_queue_dd

*&----


*

*& Form vardata_lines

*&----


*

FORM vardata_lines.

count-start = 0.

count-rest = it_apqd-varlen.

IF it_apqd-varlen < nr_cols.

count-part = it_apqd-varlen.

ELSE.

count-part = nr_cols.

ENDIF.

DO.

cspan = nr_cols - count-part.

  • 1. the ASCII - Value

b_wa-dta->new_row( sap_color = cl_dd_table_area=>list_heading ).

DO count-part TIMES.

count-index = count-start + sy-index.

READ TABLE it_cx INTO cx INDEX count-index.

IF NOT cx-hex IS INITIAL.

t = cx-char.

b_wa-dta->add_text( text = t ).

ELSE.

t = space.

b_wa-dta->add_text( text = t

sap_color = cl_dd_table_area=>list_negative ).

ENDIF.

ENDDO.

IF count-rest < nr_cols.

t = space.

DO cspan TIMES.

b_wa-dta->add_text( text = t

sap_color =

cl_dd_table_area=>list_background ).

ENDDO.

ENDIF.

IF q-show_hex = 'X'.

  • 2. at least one Byte hex-code for non-unicode systems

b_wa-dta->new_row( sap_style = cl_dd_table_area=>list_normal ).

PERFORM hex_line USING cx-xtoc+0(1).

b_wa-dta->new_row( sap_style = cl_dd_table_area=>list_normal ).

PERFORM hex_line USING cx-xtoc+1(1).

  • 3. two-byte unicode:

IF ( q-uc_bytes = 2 OR q-uc_bytes = 4 ).

b_wa-dta->new_row( sap_style = cl_dd_table_area=>list_normal ).

PERFORM hex_line USING cx-xtoc+2(1).

b_wa-dta->new_row( sap_style = cl_dd_table_area=>list_normal ).

PERFORM hex_line USING cx-xtoc+3(1).

ENDIF.

  • 3. four-byte unicode:

IF ( q-uc_bytes = 4 ).

b_wa-dta->new_row( sap_style = cl_dd_table_area=>list_normal ).

PERFORM hex_line USING cx-xtoc+4(1).

b_wa-dta->new_row( sap_style = cl_dd_table_area=>list_normal ).

PERFORM hex_line USING cx-xtoc+5(1).

b_wa-dta->new_row( sap_style = cl_dd_table_area=>list_normal ).

PERFORM hex_line USING cx-xtoc+6(1).

b_wa-dta->new_row( sap_style = cl_dd_table_area=>list_normal ).

PERFORM hex_line USING cx-xtoc+7(1).

ENDIF.

ENDIF.

b_wa-dta->new_row( sap_style = cl_dd_table_area=>list_normal ).

  • calculate new counter values for next line(s)

count-rest = count-rest - nr_cols.

IF count-rest < 0.

EXIT.

ELSE.

count-start = count-start + nr_cols.

IF count-rest < nr_cols.

count-part = count-rest.

ELSE.

count-part = nr_cols.

ENDIF.

ENDIF.

ENDDO.

ENDFORM. " vardata_lines

*&----


*

*& Form hex_line

*&----


*

  • -->P_T text

*----


*

FORM hex_line USING p_t.

DO count-part TIMES.

count-index = count-start + sy-index.

READ TABLE it_cx INTO cx INDEX count-index.

t = p_t.

b_wa-dta->add_text( text = t ).

ENDDO.

IF count-rest < nr_cols.

DO cspan TIMES.

t = space.

b_wa-dta->add_text( text = t ).

ENDDO.

ENDIF.

ENDFORM. " hex_line

*&----


*

*& Module d0701_init OUTPUT

*&----


*

MODULE d0701_init OUTPUT.

DATA:

extab TYPE STANDARD TABLE OF fcode.

REFRESH extab.

APPEND 'TOGGLE' TO extab.

APPEND 'APQI' TO extab.

SET PF-STATUS 'PF_QUEUE' EXCLUDING extab.

SET TITLEBAR 'APQI_DUMP' WITH apqi-groupid.

ENDMODULE. " d0701_init OUTPUT

*&----


*

*& Module d0701_fcode INPUT

*&----


*

MODULE d0701_fcode INPUT.

CASE d0701_fcode.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'END'.

LEAVE PROGRAM.

WHEN 'UNLOCK'.

PERFORM session_unlock.

WHEN 'TOGGLE_KEEP'.

PERFORM session_toggle_keep_flag.

WHEN OTHERS.

"nop

ENDCASE.

ENDMODULE. " d0701_fcode INPUT

*&----


*

*& Form session_unlock

*&----


*

FORM session_unlock.

DATA: user LIKE sy-uname.

AUTHORITY-CHECK OBJECT 'S_BDC_MONI'

ID 'BDCAKTI' FIELD 'LOCK'

ID 'BDCGROUPID' FIELD apqi-groupid.

IF sy-subrc <> 0. MESSAGE i394 WITH apqi-groupid. EXIT. ENDIF.

CALL FUNCTION 'ENQUEUE_BDC_QID'

EXPORTING

datatyp = 'BDC'

groupid = apqi-groupid

qid = apqi-qid

EXCEPTIONS

foreign_lock = 1

system_failure = 99.

IF sy-subrc <> 0.

CASE sy-subrc.

WHEN 1.

user = sy-msgv1.

MESSAGE i322 WITH apqi-groupid apqi-qid user.

WHEN 99. MESSAGE i353 WITH apqi-groupid.

ENDCASE.

EXIT.

ENDIF.

CLEAR apqi-startdate. UPDATE apqi. COMMIT WORK.

CALL FUNCTION 'DEQUEUE_BDC_QID'

EXPORTING

datatyp = 'BDC'

groupid = apqi-groupid

qid = apqi-qid.

  • tell SM35 to reload table APQI

EXPORT reload_apqi TO MEMORY ID 'RELOAD_APQI'.

ENDFORM. " session_unlock

*&----


*

*& Form session_toggle_keep_flag

*&----


*

FORM session_toggle_keep_flag.

DATA: user LIKE sy-uname.

  • since setting or deleting the apqi-qerase flag can be considered of

  • being equal to deleting a session, we check for the corresponding

  • authorization. There's no special 'KEEP' activity for S_BDC_MONI

AUTHORITY-CHECK OBJECT 'S_BDC_MONI'

ID 'BDCAKTI' FIELD 'DELE'

ID 'BDCGROUPID' FIELD apqi-groupid.

IF sy-subrc <> 0. MESSAGE i395 WITH apqi-groupid. EXIT. ENDIF.

CALL FUNCTION 'ENQUEUE_BDC_QID'

EXPORTING

datatyp = 'BDC'

groupid = apqi-groupid

qid = apqi-qid

EXCEPTIONS

foreign_lock = 1

system_failure = 99.

IF sy-subrc <> 0.

CASE sy-subrc.

WHEN 1.

user = sy-msgv1.

MESSAGE i322 WITH apqi-groupid apqi-qid user.

WHEN 99.

MESSAGE i353 WITH apqi-groupid.

ENDCASE.

EXIT.

ENDIF.

IF apqi-qerase = 'X'.

CLEAR apqi-qerase.

ELSE.

apqi-qerase = 'X'.

ENDIF.

UPDATE apqi. COMMIT WORK.

CALL FUNCTION 'DEQUEUE_BDC_QID'

EXPORTING

datatyp = 'BDC'

groupid = apqi-groupid

qid = apqi-qid.

  • tell SM35 to reload table APQI

EXPORT reload_apqi TO MEMORY ID 'RELOAD_APQI'.

ENDFORM. " session_toggle_keep_flag

*&----


*

*& Module d0702_init OUTPUT

*&----


*

MODULE d0702_init OUTPUT.

IF apqi-startdate IS INITIAL.

LOOP AT SCREEN.

IF screen-name = 'PB_UNLOCK'.

screen-invisible = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

ENDMODULE. " d0702_init OUTPUT

*&----


*

*& Module MARK_TCODE OUTPUT

*&----


*

MODULE mark_tcode OUTPUT.

IF ( ( tcode_index_apqd = 0 )

AND ( bdc_tcodes-index = 1st_bdc_tcode_index ) )

OR ( bdc_tcodes-index = tcode_index_apqd ).

LOOP AT SCREEN.

screen-intensified = 1. MODIFY SCREEN.

ENDLOOP.

ENDIF.

ENDMODULE. " mark_tcode output

*----


*

  • FORM count_dynpros

  • Count dynpros for a selected transaction

*----


*

FORM count_dynpros USING tcnt.

CLEAR it_apqd. REFRESH it_apqd.

SELECT * FROM apqd INTO TABLE it_apqd

WHERE qid = queue_id AND trans = tcnt.

CLEAR dynpro_cnt.

LOOP AT it_apqd.

IF it_apqd-vardata(1) = 'M'. "it's a message header

dynpro_cnt = dynpro_cnt + 1.

ENDIF.

ENDLOOP.

ENDFORM. "count_dynpros

*----


*

  • FORM recalculate_counters

  • recalculate dynpro counters

*----


*

FORM recalculate_counters.

CLEAR: apqdcnt-msgcntb,

apqdcnt-msgcnte,

apqdcnt-msgcnto,

apqdcnt-msgcntf,

apqdcnt-msgcntd,

apqdcnt-msgcnt,

apqdcnt-msgcntx,

apqdcnt-msgcntp.

LOOP AT all_bdc_tcodes.

PERFORM count_dynpros USING all_bdc_tcodes-index.

ADD dynpro_cnt TO apqdcnt-msgcnt.

CASE all_bdc_tcodes-status.

WHEN 'D' OR 'G'.

ADD dynpro_cnt TO apqdcnt-msgcntd.

WHEN 'F'.

ADD dynpro_cnt TO apqdcnt-msgcntf.

WHEN 'E'.

ADD dynpro_cnt TO apqdcnt-msgcnte.

WHEN 'B'.

ADD dynpro_cnt TO apqdcnt-msgcntb.

ENDCASE.

ENDLOOP.

apqdcnt-msgcnto = apqdcnt-msgcntb

+ apqdcnt-msgcnte.

apqdcnt-msgcntd = apqdcnt-msgcnt

- apqdcnt-msgcntf

- apqdcnt-msgcnte

- apqdcnt-msgcntb.

apqdcnt-msgcntp = apqi-putblock

- apqi-puttrans.

apqdcnt-msgcntx = apqdcnt-msgcntp

- apqdcnt-msgcnt.

show_dynpro_cnt = 'X'.

ENDFORM. "recalculate_counters

*&----


*

*& Form download

*----


*

FORM download .

REFRESH lt_string.

LOOP AT bdclm.

CONCATENATE bdclm-tcnt bdclm-longtext INTO wa_string SEPARATED BY '|'.

APPEND wa_string TO lt_string.

ENDLOOP.

filename = 'H:Errorlog.xls'.

CALL METHOD cl_gui_frontend_services=>gui_download

EXPORTING

filename = filename

filetype = 'DAT'

CHANGING

data_tab = lt_string

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

not_supported_by_gui = 22

error_no_gui = 23

OTHERS = 24.

IF sy-subrc NE 0.

MESSAGE e000(vz) WITH 'Error while'

'downloading'

'BDC log to'

filename.

ELSE.

MESSAGE s000(vz) WITH 'Log'

'downloaded'

'to'

filename.

ENDIF.

0 Kudos

Hi

Here is a sample program wherein you can download the errors into a internal table from the batch session method using the queue id from the batch session

You can change the program so that it suits your requirements.

PARAMETERS:

queue_id LIKE apqi-qid OBLIGATORY.

INCLUDE rsbdcil3. "Read plain log from TemSe

TYPE-POOLS: icon, sdydo.

TABLES:

apqi, apqd, apql, t100, snap.

CONTROLS:

tc_tcodes TYPE TABLEVIEW USING SCREEN 200,

tc_dynpro TYPE TABLEVIEW USING SCREEN 300,

tc_protocol TYPE TABLEVIEW USING SCREEN 400,

tc_bdcld TYPE TABLEVIEW USING SCREEN 600,

tc_q_tcodes TYPE TABLEVIEW USING SCREEN 700,

tab_dynpro TYPE TABSTRIP,

tab_apqi TYPE TABSTRIP.

FIELD-SYMBOLS:

.

DATA:

  • this table keeps those tcodes actually displayed

BEGIN OF bdc_tcodes OCCURS 0,

index TYPE i, tcode LIKE sy-tcode, status(1), s_text(16),

END OF bdc_tcodes,

  • this table keeps all tcodes of the session

BEGIN OF all_bdc_tcodes OCCURS 0,

index TYPE i, tcode LIKE sy-tcode, status(1), s_text(16),

END OF all_bdc_tcodes.

DATA:

  • this table keeps those dynpros actually displayed

BEGIN OF bdc_dynpro OCCURS 0,

program LIKE sy-cprog, dynpro LIKE sy-dynnr,

fnam LIKE bdcdata-fnam, fval LIKE bdcdata-fval,

index TYPE i,

END OF bdc_dynpro,

  • this table keeps all dynpros of the session

BEGIN OF all_bdc_dynpro OCCURS 0,

program LIKE sy-cprog, dynpro LIKE sy-dynnr,

fnam LIKE bdcdata-fnam, fval LIKE bdcdata-fval,

index TYPE i,

END OF all_bdc_dynpro,

dynpro_index TYPE i,

cat_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.

DATA:

  • this table keeps protocol lines to be displayed

BEGIN OF bdc_protocol OCCURS 0.

INCLUDE STRUCTURE bdclm.

DATA:

longtext TYPE bdc_mpar,

END OF bdc_protocol.

DATA:

it_apqd LIKE apqd OCCURS 0 WITH HEADER LINE,

udat LIKE apqd-vardata, sdat LIKE apqd-vardata.

DATA:

BEGIN OF tf OCCURS 0, "interne tabelle mit dynprofeldern

count TYPE i VALUE 0, "zum abmischen

trcd(4),stat(4),

pgm(8), "programmname

dyn(4) TYPE n, "dynpronummer

fname(35), farg(132), fstart(5) TYPE p, fende(5) TYPE p,

END OF tf.

  • needed for check if TemSe interface is active:

DATA: protparam(60) VALUE 'bdc/new_protocol',

newprot(3) VALUE 'off'.

  • message header

DATA:

BEGIN OF bdcmh,

mtype, state,

tcode(20), " (4 -> 20)

prog(40), " (8 -> 40)

dynr(4), sepc, filler,

END OF bdcmh.

  • transaction header

DATA:

BEGIN OF bdcth,

mtype, state,

tcode(20), " (4 -> 20)

postg, print,

msgid(20), " (2 -> 20)

END OF bdcth.

DATA:

bdcmhlen TYPE i VALUE 68, " (20 -> 68 ) MessageHeaderlaenge

dcnt TYPE i, tcnt TYPE i, gencnt TYPE i, delcnt TYPE i, wcount TYPE i,

mfstart TYPE i, mfende TYPE i, mflen TYPE i, mfart(2).

DATA BEGIN OF bdclm OCCURS 0. " ITabelle der Messageseintraege

INCLUDE STRUCTURE bdclm. " LogTabelle

DATA: counter TYPE i,

longtext TYPE bdc_mpar,

isdetail(1) TYPE c,

END OF bdclm .

DATA: lm LIKE bdclm,

save_mpar TYPE bdc_mpar.

DATA BEGIN OF bdcld OCCURS 0. " ITabelle der Verzeichniseintraege

INCLUDE STRUCTURE bdcld. " LogTabelle aller Protokolle

DATA: logname(80), " protokollpfad

local_host(12), " lokaler rechner

cnt TYPE i, " satzzaehler

active(1) TYPE c, " active flag

temseid TYPE rstsoname. " TemSe ID

DATA END OF bdcld .

DATA:

logtab LIKE bdcld OCCURS 0 WITH HEADER LINE,

logtab_temse LIKE apql OCCURS 0 WITH HEADER LINE.

DATA:

main_okcode TYPE fcode,

d0500_fcode TYPE fcode,

d0600_fcode TYPE fcode,

d0700_fcode TYPE fcode,

d0701_fcode TYPE fcode,

tc_mark(1),

counter TYPE i,

status_icon(32),

dynprotab_subscreen_dynpro LIKE sy-dynnr,

header_subscreen_dynpro LIKE sy-dynnr.

DATA:

ex_date(12), string(48), tab_proto(48).

  • Radio buttons and checkbox on screen 0500

DATA:

BEGIN OF rb,

tcodes_all VALUE 'X', tcodes_error,

fieldlist VALUE ' ',

pro_all VALUE 'X', pro_tcode, pro_session,

log_detail,

END OF rb.

DATA:

  • Flags for identifying contents of the bdc_... tables

bdc_tcodes_content(1), "a: all, e: errors

bdc_dynpro_content(1), "f: fieldlist, s: screens only

bdc_protocol_content(1), "a: all, t: for transaction, s: for session

bdc_lines LIKE sy-index,

c_field(132),

c_line TYPE i,

selected_index LIKE sy-index,

selected_protocol LIKE sy-index,

tc_index LIKE sy-index,

tc_select LIKE sy-index,

tcode_index LIKE bdc_tcodes-index,

tcode_index_apqd LIKE bdc_tcodes-index,

1st_bdc_tcode_index LIKE bdc_tcodes-index,

i_tcodes TYPE i,

i_protocols TYPE i,

tcode LIKE sy-tcode,

tcode_status(16),

previous_tab(64).

  • Data needed for CATT simulation of screens

DATA:

BEGIN OF bdc_subscreen,

program LIKE sy-cprog,

dynpro LIKE sy-dynnr,

subscr(64),

END OF bdc_subscreen.

  • Table for keeping fcodes to be excluded from pf-status

DATA:

BEGIN OF ex_cua OCCURS 2,

fcode LIKE rsmpe-func,

END OF ex_cua.

  • data for keeping scoll infos

DATA:

current_page LIKE sy-tabix VALUE 1,

new_page LIKE sy-tabix,

total_pages LIKE sy-tabix,

new_line LIKE sy-tabix,

entries LIKE sy-tabix,

loopc LIKE sy-loopc.

  • data for queue dump

DATA:

BEGIN OF q,

tcode_index LIKE all_bdc_tcodes-index,

itab_index LIKE all_bdc_tcodes-index,

c_field(132),

c_line LIKE sy-index,

c_area(132),

wa LIKE LINE OF all_bdc_tcodes,

control_init VALUE 'X',

reuse_control,

uc_bytes TYPE i,

c(1),

show_hex VALUE ' ',

END OF q.

DATA:

t TYPE sdydo_text_element,

c(128).

TYPES:

BEGIN OF block,

dt TYPE REF TO cl_dd_table_element,

dta TYPE REF TO cl_dd_table_area,

END OF block.

DATA:

it_blocks TYPE STANDARD TABLE OF block,

b_wa TYPE block.

DATA:

dd TYPE REF TO cl_dd_document,

cust TYPE REF TO cl_gui_custom_container.

TYPES:

BEGIN OF cx,

char(1) TYPE c,

hex(4) TYPE x,

xtoc(8) TYPE c,

END OF cx,

uc_1(1) TYPE x,

uc_2(2) TYPE x,

uc_4(4) TYPE x.

DATA:

it_cx TYPE STANDARD TABLE OF cx,

cx TYPE cx.

FIELD-SYMBOLS:

.

DATA:

BEGIN OF count,

start TYPE i,

index TYPE i,

part TYPE i,

rest TYPE i,

END OF count.

DATA:

cspan TYPE i.

CONSTANTS:

nr_cols TYPE i VALUE 64,

reload_apqi VALUE 'X'.

DATA:

BEGIN OF apqdcnt,

transcntb TYPE apq_tran, "neu

msgcntb TYPE apq_reco,

transcnte TYPE apq_tran, "fehlerhaft

msgcnte TYPE apq_reco,

transcnto TYPE apq_tran, "noch zu verarbeiten

msgcnto TYPE apq_reco,

transcntf TYPE apq_tran, "verarbeitet

msgcntf TYPE apq_reco,

transcntd TYPE apq_tran, "gelöscht

msgcntd TYPE apq_reco,

transcnt TYPE apq_tran, "enthält aktuell

msgcnt TYPE apq_reco,

transcntx TYPE apq_tran, "entfernt

msgcntx TYPE apq_reco,

transcntp TYPE apq_tran, "angelegt

msgcntp TYPE apq_reco,

END OF apqdcnt.

DATA:

dynpro_cnt TYPE i,

show_dynpro_cnt VALUE ' ',

filename TYPE string,

lt_string TYPE char4000 OCCURS 0,

wa_string TYPE char4000,

p_cnt(8).

*----


*

*----


*

START-OF-SELECTION.

PERFORM prepare USING queue_id.

  • CALL SCREEN 100.

*----


*

*----


*

*&----


*

*& Form prepare

*&----


*

FORM prepare USING qid TYPE apqi-qid.

CLEAR: bdc_tcodes_content, bdc_dynpro_content, bdc_protocol_content.

SELECT SINGLE * FROM apqi WHERE qid = qid.

IF sy-subrc <> 0.

MESSAGE i307(00) WITH 'Lesen'(010) 'mit Queue-ID'(011) qid.

LEAVE PROGRAM.

ENDIF.

PERFORM fill_all_bdc_tcodes. " find all transactions

PERFORM get_logfiles_for_qid. " logfiles -> bdcld

PERFORM get_log USING 1. " most recent log -> bdclm

selected_protocol = 1.

GET PARAMETER ID 'RSBDC_ANALYSE_RB' FIELD rb.

IF sy-subrc <> 0.

rb-tcodes_all = 'X'. rb-pro_all = 'X'.

ENDIF.

ex_cua-fcode = 'FL_ON'. APPEND ex_cua.

ex_cua-fcode = 'FL_OFF'. APPEND ex_cua.

ENDFORM. "prepare

*----


*

  • Module loopc

*----


*

MODULE loopc OUTPUT.

loopc = sy-loopc.

ENDMODULE. "loopc OUTPUT

*----


*

  • Module status_main

*----


*

MODULE status_main OUTPUT.

CLEAR main_okcode.

SET TITLEBAR '0100' WITH apqi-groupid.

LOOP AT SCREEN.

  • set text of tabstrip tab for protocol display or set tab invisible if

  • no protocol was found for the qid

IF screen-name = 'TAB_PROTO'.

IF selected_protocol IS INITIAL.

screen-invisible = 1. MODIFY SCREEN.

ELSE.

WRITE bdcld-edate TO ex_date.

CONCATENATE '@96@' 'Protokoll vom'(020) ex_date "ICON_HISTORY

INTO tab_proto SEPARATED BY ' '.

ENDIF.

ENDIF.

ENDLOOP.

  • set header and subscreen dynpro depending on active tab

CASE tab_dynpro-activetab.

WHEN 'TAB_TCODES'.

SET PF-STATUS 'PF_MAIN' EXCLUDING ex_cua.

dynprotab_subscreen_dynpro = '0200'.

header_subscreen_dynpro = '0201'.

WHEN 'TAB_LIST'.

IF rb-fieldlist = 'X'.

SET PF-STATUS 'PF_MAIN_NAVI' EXCLUDING 'FL_ON'.

ELSE.

SET PF-STATUS 'PF_MAIN_NAVI' EXCLUDING 'FL_OFF'.

ENDIF.

dynprotab_subscreen_dynpro = '0300'.

header_subscreen_dynpro = '0301'.

WHEN 'TAB_PROTO'.

IF rb-pro_tcode = 'X'.

SET PF-STATUS 'PF_MAIN_NAVI' EXCLUDING ex_cua.

ELSE.

SET PF-STATUS 'PF_MAIN' EXCLUDING ex_cua.

ENDIF.

dynprotab_subscreen_dynpro = '0400'.

header_subscreen_dynpro = '0401'.

WHEN OTHERS.

SET PF-STATUS 'PF_MAIN' EXCLUDING ex_cua.

tab_dynpro-activetab = 'TAB_TCODES'.

dynprotab_subscreen_dynpro = '0200'.

header_subscreen_dynpro = '0201'.

ENDCASE.

  • is this the first call?

IF tcode_index IS INITIAL.

tcode_index = 1.

tcode = all_bdc_tcodes-tcode.

tcode_status = all_bdc_tcodes-s_text.

ELSE.

  • tcode_index was already set in PAI

tcode = bdc_tcodes-tcode.

tcode_status = bdc_tcodes-s_text.

ENDIF.

ENDMODULE. "status_main OUTPUT

*----


*

  • Module exit_main

*----


*

MODULE exit_main INPUT.

SET PARAMETER ID 'RSBDC_ANALYSE_RB' FIELD rb.

LEAVE PROGRAM.

ENDMODULE. "exit_main INPUT

*----


*

  • Module user_command_main

*----


*

MODULE user_command_main INPUT.

IF tab_dynpro-activetab <> 'TAB_TCODES'.

previous_tab = tab_dynpro-activetab.

ENDIF.

CASE main_okcode.

  • change the active tab

WHEN 'TAB_TCODES'.

tab_dynpro-activetab = 'TAB_TCODES'.

WHEN 'TAB_LIST'.

tab_dynpro-activetab = 'TAB_LIST'.

WHEN 'TAB_PROTO'.

tab_dynpro-activetab = 'TAB_PROTO'.

  • select entry for display

WHEN 'DISPLAY'.

PERFORM set_new_display.

  • change the viewing options

WHEN 'VIEW_OPT'.

CALL SCREEN 500 STARTING AT 5 5.

  • show list of protocols

WHEN 'PROTO'.

IF selected_protocol > 0.

CALL SCREEN 600 STARTING AT 5 5.

ELSE.

MESSAGE s324(00).

ENDIF.

WHEN 'PROTO_REFRESH'.

  • reload protocol file (while watching running sessions)

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

text = 'Protokoll wird erneut gelesen ...'(006).

PERFORM get_log USING selected_protocol.

PERFORM extend_message_texts.

CLEAR bdc_protocol_content.

  • switch field list on or off

WHEN 'FL_ON'. rb-fieldlist = 'X'.

WHEN 'FL_OFF'. rb-fieldlist = ' '.

  • go to first transaction

WHEN 'FIRST'.

IF tcode_index > 1.

READ TABLE bdc_tcodes INDEX 1.

tcode_index = 1.

PERFORM scan_transaction USING bdc_tcodes-index.

CLEAR: bdc_dynpro_content, bdc_protocol_content.

ENDIF.

  • go to next transaction

WHEN 'NEXT'.

IF tcode_index < i_tcodes.

tcode_index = tcode_index + 1.

READ TABLE bdc_tcodes INDEX tcode_index.

PERFORM scan_transaction USING bdc_tcodes-index.

CLEAR: bdc_dynpro_content, bdc_protocol_content.

ENDIF.

  • go to previous transaction

WHEN 'PREV'.

IF tcode_index > 1.

tcode_index = tcode_index - 1.

READ TABLE bdc_tcodes INDEX tcode_index.

PERFORM scan_transaction USING bdc_tcodes-index.

CLEAR: bdc_dynpro_content, bdc_protocol_content.

ENDIF.

  • go to last transaction

WHEN 'LAST'.

IF tcode_index < i_tcodes.

tcode_index = i_tcodes.

READ TABLE bdc_tcodes INDEX i_tcodes.

PERFORM scan_transaction USING bdc_tcodes-index.

CLEAR: bdc_dynpro_content, bdc_protocol_content.

ENDIF.

  • scrolling in table controls

WHEN 'P-' OR 'P--' OR 'P' OR 'P+'.

PERFORM scrolling.

  • display queue dump

WHEN 'QUEUE'.

CALL SCREEN '0700'.

  • display header (APQI)

WHEN 'APQI'.

CALL SCREEN '0701'.

  • recalculate dynpro counters

WHEN 'DISP_CNT'.

PERFORM recalculate_counters.

  • leave this nice program

WHEN 'BACK' OR 'END'.

SET PARAMETER ID 'RSBDC_ANALYSE_RB' FIELD rb.

LEAVE PROGRAM.

WHEN OTHERS.

"

ENDCASE.

  • if field list or protocol chosen, but no transaction has been

  • scanned yet, it's now time to read the first transaction from APQD

IF ( main_okcode = 'TAB_LIST' OR

main_okcode = 'TAB_PROTO' ) AND

tcode_index_apqd IS INITIAL.

READ TABLE bdc_tcodes INDEX 1.

IF sy-subrc = 0.

PERFORM scan_transaction USING bdc_tcodes-index.

tcode_index_apqd = bdc_tcodes-index.

ENDIF.

ENDIF.

ENDMODULE. "user_command_main INPUT

*----


*

  • Module fill_bdc_tcodes

  • copy transactions from all_bdc_tcodes to bdc_tcodes

  • according to rb-settings

*----


*

MODULE fill_bdc_tcodes OUTPUT.

  • check whether contents are already up to date

IF show_dynpro_cnt = 'X'.

LOOP AT SCREEN.

IF screen-group1 = 'DCT'.

screen-invisible = 0.

screen-active = 1.

MODIFY SCREEN.

ENDIF.

IF screen-name = 'CMD_DISP_CNT'.

screen-invisible = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

IF bdc_tcodes_content = 'A' AND rb-tcodes_all = 'X'.

EXIT.

ELSEIF bdc_tcodes_content = 'E' AND rb-tcodes_error = 'X'.

EXIT.

ENDIF.

  • fill bdc_tcodes according to the settings in screen 500

CLEAR bdc_tcodes. REFRESH bdc_tcodes.

IF rb-tcodes_all ='X'.

LOOP AT all_bdc_tcodes.

bdc_tcodes = all_bdc_tcodes. APPEND bdc_tcodes.

ENDLOOP.

bdc_tcodes_content = 'A'.

ELSEIF rb-tcodes_error = 'X'.

LOOP AT all_bdc_tcodes WHERE status = 'E'.

bdc_tcodes = all_bdc_tcodes. APPEND bdc_tcodes.

ENDLOOP.

bdc_tcodes_content = 'E'.

ENDIF.

DESCRIBE TABLE bdc_tcodes LINES bdc_lines.

i_tcodes = bdc_lines.

tc_tcodes-lines = bdc_lines.

CLEAR tcode_index_apqd.

READ TABLE bdc_tcodes INDEX 1.

1st_bdc_tcode_index = bdc_tcodes-index.

tcode_index = 1.

ENDMODULE. "fill_bdc_tcodes OUTPUT

*----


*

  • Module fill_bdc_dynpro

  • copy dynpro data from all_bdc_dynpro to bdc_bdc_dynpro

  • according to rb-settings

*----


*

MODULE fill_bdc_dynpro OUTPUT.

DATA: wa LIKE LINE OF tc_dynpro-cols,

tline LIKE sy-index.

tline = tc_dynpro-top_line.

tc_dynpro-top_line = tline.

  • hide fields if no detailed field list shall be displayed

LOOP AT tc_dynpro-cols INTO wa.

IF sy-tabix = 3 OR sy-tabix = 4.

IF rb-fieldlist = 'X'.

CLEAR wa-invisible.

ELSE.

wa-invisible = 1.

ENDIF.

MODIFY tc_dynpro-cols FROM wa.

ENDIF.

ENDLOOP.

  • is bdc_dynpro_content already correctly filled ?

IF rb-fieldlist = ' ' AND bdc_dynpro_content = 'S'.

EXIT.

ELSEIF rb-fieldlist = 'X' AND bdc_dynpro_content = 'F'.

EXIT.

ENDIF.

CLEAR bdc_dynpro. REFRESH bdc_dynpro.

IF rb-fieldlist = ' '.

LOOP AT all_bdc_dynpro WHERE NOT program IS INITIAL.

bdc_dynpro = all_bdc_dynpro.

APPEND bdc_dynpro.

ENDLOOP.

bdc_dynpro_content = 'S'.

ELSEIF rb-fieldlist = 'X'.

LOOP AT all_bdc_dynpro.

bdc_dynpro = all_bdc_dynpro.

APPEND bdc_dynpro.

ENDLOOP.

bdc_dynpro_content = 'F'.

ENDIF.

DESCRIBE TABLE bdc_dynpro LINES bdc_lines.

tc_dynpro-lines = bdc_lines.

tc_dynpro-top_line = 1.

ENDMODULE. "fill_bdc_dynpro OUTPUT

*----


*

  • Module fill_bdc_protocol

  • copy messages from bdclm to bdc_protocol

  • according to rb-settings

*----


*

MODULE fill_bdc_protocol OUTPUT.

IF rb-pro_all = 'X' AND bdc_protocol_content = 'A'.

EXIT.

ELSEIF rb-pro_tcode = 'X' AND bdc_protocol_content = 'T'.

EXIT.

ELSEIF rb-pro_session = 'X' AND bdc_protocol_content = 'S'.

EXIT.

ENDIF.

CLEAR bdc_protocol. REFRESH bdc_protocol.

IF rb-pro_all = 'X'.

LOOP AT bdclm.

IF rb-log_detail = ' ' AND bdclm-isdetail = 'X'.

CONTINUE.

ENDIF.

MOVE-CORRESPONDING bdclm TO bdc_protocol.

APPEND bdc_protocol.

ENDLOOP.

bdc_protocol_content = 'A'.

ELSEIF rb-pro_tcode = 'X'.

LOOP AT bdclm WHERE tcnt = tcode_index_apqd.

IF rb-log_detail = ' ' AND bdclm-isdetail = 'X'.

CONTINUE.

ENDIF.

MOVE-CORRESPONDING bdclm TO bdc_protocol.

APPEND bdc_protocol.

ENDLOOP.

bdc_protocol_content = 'T'.

ELSEIF rb-pro_session = 'X'.

LOOP AT bdclm WHERE tcnt = ' '.

MOVE-CORRESPONDING bdclm TO bdc_protocol.

APPEND bdc_protocol.

ENDLOOP.

bdc_protocol_content = 'S'.

ENDIF.

DESCRIBE TABLE bdc_protocol LINES bdc_lines.

tc_protocol-lines = bdc_lines.

tc_protocol-top_line = 1.

ENDMODULE. "fill_bdc_protocol OUTPUT

*----


*

  • Module check_bdc_tcodes

*----


*

MODULE check_bdc_protocol OUTPUT.

  • display lines intensified if they contain e- or a-messages

IF bdc_protocol-mart = 'E'

OR bdc_protocol-mart = 'A'.

LOOP AT SCREEN.

screen-intensified = 1. MODIFY SCREEN.

ENDLOOP.

ENDIF.

  • skip empty lines

IF bdc_protocol-indate IS INITIAL.

EXIT FROM STEP-LOOP.

ENDIF.

ENDMODULE. "check_bdc_protocol OUTPUT

*----


*

  • Module get_cursor_position

*----


*

MODULE get_cursor_position INPUT.

GET CURSOR FIELD c_field LINE c_line.

IF c_line > 0.

CASE tab_dynpro-activetab.

WHEN 'TAB_TCODES'.

selected_index = tc_tcodes-top_line + c_line - 1.

WHEN 'TAB_LIST'.

selected_index = tc_dynpro-top_line + c_line - 1.

WHEN 'TAB_PROTO'.

selected_index = tc_protocol-top_line + c_line - 1.

ENDCASE.

ELSE.

selected_index = 0.

ENDIF.

ENDMODULE. "get_cursor_position INPUT

*----


*

  • Module d0500_init

*----


*

MODULE d0500_init OUTPUT.

SET PF-STATUS 'POPUP'.

SET TITLEBAR '0500'.

ENDMODULE. "d0500_init OUTPUT

*----


*

  • Module d0500_fcode

*----


*

MODULE d0500_fcode INPUT.

LEAVE TO SCREEN 0.

ENDMODULE. "d0500_fcode INPUT

*----


*

  • Module d0600_init

*----


*

MODULE d0600_init OUTPUT.

SET PF-STATUS 'POPUP'.

SET TITLEBAR '0600'.

CLEAR d0600_fcode.

DESCRIBE TABLE bdcld LINES i_protocols.

tc_bdcld-lines = i_protocols.

ENDMODULE. "d0600_init OUTPUT

*----


*

  • Module d0500_fcode

  • read and process another protocol which was selected on

  • popup dynpro 500

*----


*

MODULE d0600_fcode INPUT.

CASE d0600_fcode.

WHEN 'POP_CANCEL'.

LEAVE TO SCREEN 0.

WHEN 'POP_OKAY'.

  • read selected protocol

IF tc_select <> selected_protocol.

CLEAR bdclm. REFRESH bdclm.

CLEAR bdc_protocol_content.

PERFORM get_log USING tc_select.

PERFORM extend_message_texts.

selected_protocol = tc_select.

ENDIF.

LEAVE TO SCREEN 0.

WHEN OTHERS.

  • scroll in table

ENDCASE.

ENDMODULE. "d0600_fcode INPUT

*----


*

  • Module set_mark

  • set table view marker for the actual selected protocol

  • (dynpro 500)

*----


*

MODULE set_mark OUTPUT.

tc_index = tc_bdcld-top_line + tc_bdcld-current_line - 1.

IF tc_index = selected_protocol.

tc_mark = 'X'.

ENDIF.

ENDMODULE. "set_mark OUTPUT

*----


*

  • Module get_mark

  • get index of selected protocol on popup 500

*----


*

MODULE get_mark INPUT.

IF tc_mark = 'X'.

tc_select = tc_bdcld-top_line + tc_bdcld-current_line - 1.

ENDIF.

ENDMODULE. "get_mark INPUT

*----


*

  • FORM: fill_bdc_tcodes

  • Read all transaction codes from apqd and fill internal table

*----


*

FORM fill_all_bdc_tcodes.

  • read APQD blocks 1 for QID

CLEAR all_bdc_tcodes. REFRESH all_bdc_tcodes.

SELECT * FROM apqd WHERE qid = queue_id AND block = 1

ORDER BY PRIMARY KEY.

MOVE apqd-vardata TO bdcth.

all_bdc_tcodes-index = apqd-trans.

all_bdc_tcodes-tcode = bdcth-tcode.

all_bdc_tcodes-status = bdcth-state.

APPEND all_bdc_tcodes.

ENDSELECT.

  • convert status flag to long text

  • calculate transaction counters

CLEAR apqdcnt.

LOOP AT all_bdc_tcodes.

ADD 1 TO apqdcnt-transcnt.

CASE all_bdc_tcodes-status.

WHEN 'D' OR 'G'.

all_bdc_tcodes-s_text = 'gelöscht'(005).

ADD 1 TO apqdcnt-transcntd.

WHEN 'F'.

all_bdc_tcodes-s_text = 'verarbeitet'(002).

ADD 1 TO apqdcnt-transcntf.

WHEN 'E'.

all_bdc_tcodes-s_text = 'fehlerhaft'(001).

ADD 1 TO apqdcnt-transcnte.

WHEN 'B'.

all_bdc_tcodes-s_text = ' '. "neu

ADD 1 TO apqdcnt-transcntb.

WHEN OTHERS.

all_bdc_tcodes-s_text = ' '.

ENDCASE.

MODIFY all_bdc_tcodes.

ENDLOOP.

apqdcnt-transcnto = apqdcnt-transcntb

+ apqdcnt-transcnte.

apqdcnt-transcntd = apqdcnt-transcnt

- apqdcnt-transcntf

- apqdcnt-transcnte

- apqdcnt-transcntb.

apqdcnt-transcntp = apqi-puttrans.

apqdcnt-transcntx = apqdcnt-transcntp

- apqdcnt-transcnt.

IF apqi-msgcnt < 1000.

PERFORM recalculate_counters.

ENDIF.

ENDFORM. "fill_all_bdc_tcodes

*----


*

  • FORM scan_transaction

  • Read all APQD data for a selected transaction

*----


*

FORM scan_transaction USING tcnt.

CLEAR it_apqd. REFRESH it_apqd.

CLEAR all_bdc_dynpro. REFRESH all_bdc_dynpro.

SELECT * FROM apqd INTO TABLE it_apqd

WHERE qid = queue_id AND trans = tcnt.

tcode_index_apqd = tcnt. "Display correct index in header screens

CLEAR dynpro_index.

LOOP AT it_apqd.

IF it_apqd-vardata(1) = 'M'. "it's a message header

dynpro_index = dynpro_index + 1.

PERFORM scan_dynpro.

ENDIF.

ENDLOOP.

ENDFORM. "scan_transaction

*----


*

  • FORM: scan_dynpro

  • Scan APQD data for a single dynpro screen

  • and put it into a BDCDATA table

*----


*

FORM scan_dynpro.

*

MOVE it_apqd-vardata TO bdcmh.

TRANSLATE bdcmh TO UPPER CASE.

  • get program name and screen number

CLEAR all_bdc_dynpro.

all_bdc_dynpro-index = dynpro_index.

all_bdc_dynpro-program = bdcmh-prog.

all_bdc_dynpro-dynpro = bdcmh-dynr.

APPEND all_bdc_dynpro.

  • get all the fnam/fval pairs

MOVE it_apqd-vardata TO sdat.

SHIFT sdat BY bdcmhlen PLACES.

wcount = bdcmhlen.

mfstart = wcount.

mfart = 'FN'.

WHILE wcount LE it_apqd-varlen.

IF sdat(1) = bdcmh-sepc.

mfende = wcount.

PERFORM move_tf.

ENDIF.

SHIFT sdat.

wcount = wcount + 1.

ENDWHILE.

ENDFORM. "scan_dynpro

*----


*

  • Parse the apqd-vardata field for FNAM/FVAL pairs

  • FORM: move_tf

  • fills TF-FNAME and TF-FARG

*----


*

FORM move_tf.

mflen = mfende - mfstart.

CASE mfart.

WHEN 'FN'.

CLEAR: tf-fname, udat.

tf-fstart = mfstart.

MOVE it_apqd-vardata TO udat.

SHIFT udat BY mfstart PLACES.

WRITE udat TO tf-fname+0(mflen).

TRANSLATE tf-fname TO UPPER CASE.

mfstart = mfende + 1.

mfende = 0.

MOVE 'FA' TO mfart.

WHEN 'FA'.

CLEAR: tf-farg, udat.

tf-fende = mfende.

MOVE it_apqd-vardata TO udat.

SHIFT udat BY mfstart PLACES.

WRITE udat TO tf-farg+0(mflen).

APPEND tf.

tf-stat = space.

mfstart = mfende + 1.

mfende = 0.

MOVE 'FN' TO mfart.

  • copy to bdcdata table if fname/fval is not empty

CHECK NOT tf-fname IS INITIAL.

  • CHECK NOT TF-FARG IS INITIAL.

CLEAR all_bdc_dynpro.

all_bdc_dynpro-index = dynpro_index.

all_bdc_dynpro-fnam = tf-fname.

all_bdc_dynpro-fval = tf-farg.

APPEND all_bdc_dynpro.

WHEN OTHERS.

ENDCASE.

ENDFORM. "move_tf

*----


*

  • Form: get_logfiles_for_qid

*----


*

DATA:

paramname(11) VALUE 'bdc/logfile',

logname(80),

logname1(80),

old_logfile(06) VALUE 'bdclog',

new_logfile(04) VALUE 'BI* ',

shiftlen TYPE i VALUE 0,

protflen TYPE i VALUE 0,

protfoff TYPE i VALUE 0,

rlen TYPE i VALUE 0,

bdcld# TYPE i, one TYPE i, ec TYPE i, return TYPE i,

protcnt TYPE i.

DATA:

BEGIN OF prot_list OCCURS 0.

INCLUDE rstr0112.

DATA: seen(1), to_be_deleted(1), has_changed(1), local_host(24),

END OF prot_list.

DATA:

BEGIN OF file.

INCLUDE rstr0112.

DATA END OF file.

DATA:

BEGIN OF bdclda OCCURS 0.

INCLUDE STRUCTURE bdcld.

DATA END OF bdclda .

DATA:

digits(10) TYPE c VALUE '0123456789',

mtext(124) TYPE c, "Messagetext

mtext1(124) TYPE c, "Messagetext

mtext2(273) TYPE c, "Messagetext

do_condense TYPE c,

mtvaroff TYPE i,

showtyp(05) TYPE c, "showtyp

lmapn(12) TYPE c, "Hilfsfeld log-mapn

date1 TYPE d,

linct0 LIKE sy-linct,

parcnt TYPE i,

sp_len TYPE i,

charcnt TYPE i,

wcnt TYPE i,

mparcnt TYPE i,

qfound(04) TYPE n,

x(1) VALUE 'X'.

DATA: "Aufbereitung Messagetext

BEGIN OF mt,

off(02) TYPE n,

len(02) TYPE n,

text(80),

END OF mt.

DATA: "Aufbereitung Messagetext

BEGIN OF mttab OCCURS 4,

off(02) TYPE n,

len(02) TYPE n,

text(80),

END OF mttab.

DATA: "Hilfsfelder

BEGIN OF old,

tcnt LIKE bdclm-tcnt,

mcnt LIKE bdclm-mcnt,

END OF old.

DATA: "ParameterAufbereitung

BEGIN OF par,

len(02) TYPE n,

text(254),

END OF par.

*----


*

  • Form get_logfiles_for_qid

  • find all log files for the session in analysis,

  • either in common log or in TemSe

*----


*

FORM get_logfiles_for_qid.

  • get logs from TemSe

PERFORM get_logfiles_from_temse.

  • now bdcld contains the log files for the given qid

SORT bdcld BY edate DESCENDING etime DESCENDING.

DESCRIBE TABLE bdcld LINES selected_protocol.

ENDFORM. "get_logfiles_for_qid

*----


*

  • Form: log_dir

*----


*

FORM log_dir.

*

CLEAR bdclda. REFRESH bdclda.

CALL 'ReadLogDirA' ID 'LOGN' FIELD logname

ID 'DTAB' FIELD bdclda-sys

ID 'AINF' FIELD one

ID 'ECNT' FIELD ec.

*

IF sy-subrc NE 0 OR ec = 0.

EXIT.

ENDIF.

LOOP AT bdclda WHERE lmand = sy-mandt AND quid = queue_id.

MOVE-CORRESPONDING bdclda TO bdcld.

MOVE logname TO bdcld-logname.

MOVE prot_list-local_host TO bdcld-local_host.

APPEND bdcld.

ENDLOOP.

ENDFORM. " log_dir.

*----


*

  • Form: list_protocol_files

  • Suche nach allen aktiven Protokolldateien -> Tabelle prot_list

*----


*

FORM list_protocol_files.

CLEAR: logname1, prot_list, protcnt.

REFRESH: prot_list.

protflen = STRLEN( logname ).

MOVE logname TO logname1.

WHILE shiftlen LE protflen.

IF logname1 CP '#B#I'. "suchen nach muster #B#I

IF sy-fdpos EQ 0. "nur großbuchstaben

shiftlen = 2.

ELSE.

shiftlen = sy-fdpos.

ENDIF.

protfoff = protfoff + shiftlen.

SHIFT logname1 BY shiftlen PLACES.

ELSE.

shiftlen = protflen + 1.

protfoff = protfoff - 2.

ENDIF.

ENDWHILE.

*

IF protfoff LE 0.

protfoff = 0.

ENDIF.

*

rlen = 80 - protfoff.

*

WRITE space TO logname+protfoff(rlen).

WRITE new_logfile TO logname+protfoff(4).

*

PERFORM search_prot USING logname.

ENDFORM. " FILL_PROT_LIST

*

*----


*

  • FORM : search_prot *

*----


*

FORM search_prot USING prot_files.

*

DATA: errcnt(2) TYPE p VALUE 0.

*

CALL 'C_DIR_READ_START' ID 'FILE' FIELD prot_files

ID 'ERRNO' FIELD file-errno

ID 'ERRMSG' FIELD file-errmsg.

IF sy-subrc <> 0.

MESSAGE i398(00)

WITH sy-subrc 'C_DIR_READ_START' ' ' prot_files.

MESSAGE i398(00)

WITH sy-subrc 'C_DIR_READ_START...'

file-errno file-errmsg.

ENDIF.

DO. "aufbau der internen tabelle fuer alle

"BI-Protokolle

CLEAR file.

CALL 'C_DIR_READ_NEXT'

ID 'TYPE' FIELD file-type

ID 'NAME' FIELD file-name

ID 'LEN' FIELD file-len

ID 'OWNER' FIELD file-owner

ID 'MTIME' FIELD file-mtime

ID 'MODE' FIELD file-mode

ID 'ERRNO' FIELD file-errno

ID 'ERRMSG' FIELD file-errmsg.

MOVE sy-subrc TO file-subrc.

CASE sy-subrc.

WHEN 0.

CASE file-type(1).

WHEN 'F'. " normal file.

MOVE 1 TO file-useable.

WHEN 'f'. " normal file.

MOVE 1 TO file-useable.

WHEN OTHERS. " Directory, device, fifo, socket,...

MOVE 0 TO file-useable.

ENDCASE.

IF file-len = 0.

MOVE 0 TO file-useable.

ENDIF.

WHEN 1.

EXIT.

WHEN OTHERS. " SY-SUBRC >= 2

ADD 1 TO errcnt.

IF errcnt > 10.

EXIT.

ENDIF.

IF sy-subrc = 5.

MOVE: '???' TO file-type,

'???' TO file-owner,

'???' TO file-mode.

ELSE.

ENDIF.

file-useable = 0.

ENDCASE.

MOVE-CORRESPONDING file TO prot_list.

SHIFT file-name BY protfoff PLACES.

prot_list-local_host = file-name.

protcnt = protcnt + 1.

APPEND prot_list.

ENDDO.

CALL 'C_DIR_READ_FINISH'

ID 'ERRNO' FIELD file-errno

ID 'ERRMSG' FIELD file-errmsg.

IF sy-subrc <> 0.

  • WRITE: / 'C_DIR_READ_FINISH'(999), 'SUBRC', SY-SUBRC.

ENDIF.

ENDFORM. " search_prot

*----


*

  • Form: get_log

*----


*

FORM get_log USING log_index.

DATA: BEGIN OF logtable OCCURS 50, " plain log information in TemSe

enterdate LIKE btctle-enterdate,

entertime LIKE btctle-entertime,

logmessage(400) TYPE c,

END OF logtable.

DATA:

external_date(10),

internal_date TYPE d.

LOOP AT bdcld.

logname = bdcld-logname.

IF newprot = 'OFF'.

  • get logfile contents from common log file

CALL 'ReadLogPartitionA' ID 'LOGN' FIELD logname

ID 'ETAB' FIELD bdclm-sys

ID 'PART' FIELD bdcld

ID 'ECNT' FIELD ec.

IF sy-subrc <> 0. MESSAGE s325(00). ENDIF.

IF ec = 0. MESSAGE s324(00). ENDIF.

ELSE.

  • get logfile contents from TemSe

PERFORM read_bdc_log_plain

TABLES logtable

USING bdcld-temseid bdcld-lmand.

IF sy-subrc <> 0. " Fehler beim Lesen

MESSAGE s004(ts).

EXIT.

ENDIF.

CLEAR bdclm[].

LOOP AT logtable.

*----


*

  • Es wird geprüft, ob von TEMSE das Datum korrekt geliefert wurde

  • wenn nicht wird einfach der Satz ignoriert und nicht gelesen

*----


*

CALL 'DATE_CONV_INT_TO_EXT'

ID 'DATINT' FIELD logtable-enterdate

ID 'DATEXT' FIELD external_date.

CALL 'DATE_CONV_EXT_TO_INT'

ID 'DATEXT' FIELD external_date

ID 'DATINT' FIELD internal_date.

IF sy-subrc NE 0. " Datum ist nicht gültig

CONTINUE.

ENDIF.

CLEAR bdclm.

bdclm-indate = logtable-enterdate.

bdclm-intime = logtable-entertime.

bdclm+14(352) = logtable-logmessage.

IF bdclm-mcnt > 0.

bdclm-mcnt = bdclm-mcnt - 1.

ENDIF.

IF bdclm-mid EQ '00'.

IF ( bdclm-mnr EQ '162' )

OR ( bdclm-mnr EQ '368' ).

bdclm-isdetail = 'X'.

ENDIF.

ENDIF.

APPEND bdclm.

ENDLOOP.

PERFORM extend_message_texts. " extended texts -> bdclm

PERFORM download.

ENDIF.

ENDLOOP.

ENDFORM. "get_log

*----


*

  • Form: get_logfiles_from_temse

*----


*

FORM get_logfiles_from_temse.

  • are there any logs in the TemSe for this QID ?

CLEAR logtab_temse[].

CLEAR bdcld[].

SELECT * FROM apql INTO TABLE logtab_temse

WHERE qid = apqi-qid.

CHECK sy-subrc = 0.

  • some logs were found: now put this info into table bdcld.

DATA: wa_log LIKE LINE OF logtab_temse,

wa_ld LIKE LINE OF bdcld.

LOOP AT logtab_temse INTO wa_log.

CLEAR wa_ld.

wa_ld-temseid = wa_log-temseid.

wa_ld-lmand = wa_log-mandant.

wa_ld-edate = wa_log-credate.

wa_ld-etime = wa_log-cretime.

wa_ld-luser = wa_log-creator.

wa_ld-grpn = wa_log-groupid.

wa_ld-quid = wa_log-qid.

wa_ld-local_host = wa_log-destsys(8).

APPEND wa_ld TO bdcld.

ENDLOOP.

ENDFORM. "get_logfiles_from_temse

*----


*

  • Form: extend_message_texts

*----


*

FORM extend_message_texts.

LOOP AT bdclm.

lm = bdclm. save_mpar = bdclm-mpar.

PERFORM get_text.

bdclm-longtext = mtext.

bdclm-mpar = save_mpar.

MODIFY bdclm.

ENDLOOP.

ENDFORM. "extend_message_texts

*----


*

  • FORM : get_text *

*----


*

FORM get_text.

*

      • Aufbereiten des Messagetextes

*

DATA: shiftln TYPE i,

vartcnt TYPE i,

fdpos LIKE sy-fdpos.

IF bdclm-mparcnt CN digits. "Korrupter Datensatz:

bdclm-mparcnt = 0. "z.B. Hexnullen

ENDIF.

SELECT SINGLE * FROM t100

WHERE sprsl = sy-langu

AND arbgb = bdclm-mid

AND msgnr = bdclm-mnr.

*

IF sy-subrc EQ 0.

CLEAR: mtext,

parcnt,

mparcnt,

charcnt,

wcnt,

mt,

sp_len,

sy-fdpos.

*

MOVE bdclm-mparcnt TO mparcnt.

*

IF t100-text CA '$&'. "Kennung fuer parameter:

MOVE t100-text TO mtext1. " alt '$' --- neu '&'

ELSE.

MOVE t100-text TO mtext.

EXIT.

ENDIF.

  • variable teile aus batch-input protokoll in mttab bringen.

REFRESH mttab.

CLEAR shiftln.

DO mparcnt TIMES.

CLEAR: par, mttab.

MOVE bdclm-mpar TO par.

IF par-len CN digits OR par-len EQ 0. "convert_no_number

par-len = 1. "entschärfen

par-text = ' '.

shiftln = 2.

ELSE.

shiftln = par-len + 2.

ENDIF.

WRITE par-text TO mttab-text(par-len).

MOVE par-len TO mttab-len.

MOVE mparcnt TO mttab-off.

APPEND mttab.

SHIFT bdclm-mpar BY shiftln PLACES.

ENDDO.

*

mtext2 = mtext1.

IF bdclm-mid EQ '00' AND " sonderbehandlung s00368

bdclm-mnr EQ '368' AND

bdclm-mart EQ 'S'.

CLEAR mtext2.

CLEAR mttab.

READ TABLE mttab INDEX 1.

WRITE mttab-text TO mtext2+0(mttab-len).

CLEAR mttab.

READ TABLE mttab INDEX 2.

WRITE mttab-text TO mtext2+35(mttab-len).

mtext = mtext2.

EXIT.

ENDIF.

do_condense = x.

CLEAR: mt, vartcnt, mtvaroff.

WHILE vartcnt LE 3.

vartcnt = vartcnt + 1.

IF mtext1 CA '$&'.

parcnt = parcnt + 1.

IF sy-fdpos GT 0.

fdpos = sy-fdpos - 1. " neu sy-fdpos -1

ELSE.

fdpos = sy-fdpos.

ENDIF.

SHIFT mtext1 BY sy-fdpos PLACES.

IF mtext1(1) EQ '&'.

SHIFT mtext1 BY 1 PLACES.

CASE mtext1(1).

WHEN ' '. "'& '

PERFORM replace_var USING '& ' parcnt fdpos.

WHEN '$'. "'&&'

PERFORM replace_var USING '&&' 0 fdpos.

WHEN '1'. "'&1'

PERFORM replace_var USING '&1' 1 fdpos.

WHEN '2'. "'&2'

PERFORM replace_var USING '&2' 2 fdpos.

WHEN '3'. "'&3'

PERFORM replace_var USING '&3' 3 fdpos.

WHEN '4'. "'&4'

PERFORM replace_var USING '&4' 4 fdpos.

WHEN OTHERS. "'&'

PERFORM replace_var USING '&<' parcnt fdpos.

ENDCASE.

ENDIF.

IF mtext1(1) EQ '$'.

SHIFT mtext1 BY 1 PLACES.

CASE mtext1(1).

WHEN ' '. "'$ '

PERFORM replace_var USING '$ ' parcnt fdpos.

WHEN '$'. "'$$'

PERFORM replace_var USING '$$' 0 fdpos.

WHEN '1'. "'$1'

PERFORM replace_var USING '$1' 1 fdpos.

WHEN '2'. "'$2'

PERFORM replace_var USING '$2' 2 fdpos.

WHEN '3'. "'$3'

PERFORM replace_var USING '$3' 3 fdpos.

WHEN '4'. "'$4'

PERFORM replace_var USING '$4' 4 fdpos.

WHEN OTHERS. "'$'

PERFORM replace_var USING '$<' parcnt fdpos.

ENDCASE.

ENDIF.

ENDIF.

ENDWHILE.

*

IF mtext2 CA '%%_D_%%'.

REPLACE '%%_D_%%' WITH '$' INTO mtext2.

ENDIF.

IF mtext2 CA '%%_A_%%'.

REPLACE '%%_A_%%' WITH '&' INTO mtext2.

ENDIF.

IF do_condense EQ space.

mtext = mtext2.

ELSE.

CONDENSE mtext2 .

mtext = mtext2.

ENDIF.

ELSE.

mtext = '???????????????????????????????????????????????????'.

ENDIF.

*

ENDFORM. " get_text1

*----


*

  • FORM : replace_var *

  • *

*----


*

FORM replace_var USING vark vari varpos.

*

  • ersetzen der variablen teile einer fehlermeldung

*

DATA: var(02),

var1,

moff TYPE i.

*

CLEAR: mttab , moff.

var = vark.

SHIFT var BY 1 PLACES.

CASE var.

WHEN ' '. "'& '

READ TABLE mttab INDEX vari.

IF sy-subrc EQ 0.

moff = varpos + mtvaroff.

ASSIGN mtext2+moff(*) TO . "neu

mtvaroff = 7. "neu

ENDIF.

ENDIF.

*

ENDCASE.

*

do_condense = space.

*

ENDFORM. "replace_var

*----


*

  • Form: set_new_display

*----


*

FORM set_new_display.

CASE tab_dynpro-activetab.

WHEN 'TAB_TCODES'.

  • F2 in tcodes list: choose new transaction:

CHECK selected_index > 0.

READ TABLE bdc_tcodes INDEX selected_index.

CHECK sy-subrc = 0.

PERFORM scan_transaction USING bdc_tcodes-index.

CLEAR: bdc_dynpro_content, bdc_protocol_content.

tcode_index = selected_index.

tcode_status = bdc_tcodes-s_text.

tcode = bdc_tcodes-tcode.

IF previous_tab IS INITIAL.

tab_dynpro-activetab = 'TAB_LIST'.

ELSE.

tab_dynpro-activetab = previous_tab.

ENDIF.

WHEN 'TAB_LIST'.

  • F2 in screens list: simulate screen

CHECK selected_index > 0.

  • simulate screen

PERFORM simulate_dynpro.

WHEN 'TAB_PROTO'.

  • F2 in protocol list: show message long text:

CHECK selected_index > 0.

READ TABLE bdc_protocol INDEX selected_index.

CHECK sy-subrc = 0.

PERFORM show_ltext.

ENDCASE.

ENDFORM. "set_new_display

*----


*

  • FORM : show_ltext

  • display long text for a log message

*----


*

FORM show_ltext.

*

DATA:

docnt TYPE i.

DATA:

BEGIN OF my,

msgv1 LIKE sy-msgv1,

msgv2 LIKE sy-msgv2,

msgv3 LIKE sy-msgv3,

msgv4 LIKE sy-msgv4,

END OF my.

DATA:

msg_text LIKE shkontext-meldung,

msg_arbgb LIKE shkontext-meld_id,

msg_nr LIKE shkontext-meld_nr,

msg_title LIKE shkontext-titel.

*

  • RABAX- or T100 message ?

*

IF bdc_protocol-mid EQ '00' AND "Rabax

bdc_protocol-mnr EQ '341'.

CLEAR: par.

  • extract Rabax-ID and key fields from message string

par = bdc_protocol-mpar.

IF par-len CN digits. EXIT. ENDIF. "corrupt string"

my-msgv1 = par-text(par-len).

SHIFT par LEFT BY par-len PLACES.

SHIFT par LEFT BY 2 PLACES.

IF par-len CN digits. EXIT. ENDIF. "corrupt string"

snap = par-text(par-len).

  • Rabax display

CALL DIALOG 'RS_RUN_TIME_ERROR'

EXPORTING

snap-mandt

snap-datum

snap-uzeit

snap-ahost

snap-uname

snap-modno.

EXIT.

ENDIF.

*

  • no RABAX

*

docnt = 0.

*

CLEAR: my.

IF bdc_protocol-mparcnt CN digits. "Korrupter Datensatz:

bdc_protocol-mparcnt = 0. "z.B. Hexnullen

ENDIF.

DO bdc_protocol-mparcnt TIMES.

IF bdc_protocol-mpar(1) EQ space.

EXIT.

ENDIF.

docnt = docnt + 1.

CLEAR par.

MOVE bdc_protocol-mpar TO par.

*

IF par-len CN digits. "convert_no_number

par-len = 1. "entschärfen

ENDIF.

*

CASE docnt.

WHEN 1.

WRITE par-text TO my-msgv1(par-len).

WHEN 2.

WRITE par-text TO my-msgv2(par-len).

WHEN 3.

WRITE par-text TO my-msgv3(par-len).

WHEN 4.

WRITE par-text TO my-msgv4(par-len).

ENDCASE.

par-len = par-len + 2.

SHIFT bdc_protocol-mpar BY par-len PLACES.

ENDDO.

msg_arbgb = bdc_protocol-mid.

msg_nr = bdc_protocol-mnr.

msg_text = mtext.

msg_title = sy-title.

CALL FUNCTION 'HELPSCREEN_NA_CREATE'

EXPORTING

meldung = msg_text

meld_id = msg_arbgb

meld_nr = msg_nr

msgv1 = my-msgv1

msgv2 = my-msgv2

msgv3 = my-msgv3

msgv4 = my-msgv4

titel = msg_title.

ENDFORM. " show_ltext.

*----


*

  • FORM: simulate_dynpro

  • use function module CAT_SIMULATE_DYNPRO to simulate a dynpro

  • with contents according to APQD data of session

*----


*

FORM simulate_dynpro.

DATA:

cat_okcode LIKE sy-ucomm,

cat_params LIKE catp OCCURS 0 WITH HEADER LINE,

on_subscreen.

CLEAR cat_bdcdata. REFRESH cat_bdcdata.

READ TABLE bdc_dynpro INDEX selected_index.

LOOP AT all_bdc_dynpro WHERE index = bdc_dynpro-index.

MOVE-CORRESPONDING all_bdc_dynpro TO cat_bdcdata.

APPEND cat_bdcdata.

ENDLOOP.

READ TABLE cat_bdcdata INDEX 1.

cat_bdcdata-dynbegin = 'X'. MODIFY cat_bdcdata INDEX 1.

  • now we need some extra work to generate the correct input data

  • format for FUNCTION 'CAT_SIMULATE_DYNPRO' for subscreen fields.

CLEAR on_subscreen.

LOOP AT cat_bdcdata.

  • check if there is a new subscreen

IF cat_bdcdata-fnam = 'BDC_SUBSCR'.

MOVE cat_bdcdata-fval TO bdc_subscreen.

CLEAR cat_bdcdata-fval.

CONCATENATE bdc_subscreen-program

bdc_subscreen-dynpro

bdc_subscreen-subscr

INTO cat_bdcdata-fval SEPARATED BY ' '.

MODIFY cat_bdcdata.

on_subscreen = 'X'.

ENDIF.

ENDLOOP.

READ TABLE cat_bdcdata INDEX 1.

SET PF-STATUS 'CSIM'.

SET TITLEBAR '0300' WITH cat_bdcdata-program cat_bdcdata-dynpro.

MESSAGE s223(tt).

CALL FUNCTION 'CAT_SIMULATE_DYNPRO'

EXPORTING

mpool = cat_bdcdata-program

dynnr = cat_bdcdata-dynpro

display_only = 'X'

own_status_title = 'X'

TABLES

fielddata = cat_bdcdata

paramlist = cat_params

EXCEPTIONS

no_dynpro = 1

dynpro_not_found = 2

gen_error = 3

enq_error = 4

subscr_error = 5

OTHERS = 6.

CASE sy-subrc.

WHEN 1. MESSAGE s221(tt).

WHEN 2.

MESSAGE s219(tt)

WITH cat_bdcdata-program cat_bdcdata-dynpro.

WHEN 3. MESSAGE s236(tt) WITH ' ' ' '.

WHEN 4. MESSAGE s215(tt).

WHEN 5. MESSAGE s238(tt) WITH ' ' ' '.

WHEN 6. MESSAGE s258(00).

ENDCASE.

ENDFORM. "simulate_dynpro

*----


*

  • Form: scrolling

  • scrolling in table controls according to SAP style guide

*----


*

FORM scrolling.

DATA:

top_line LIKE sy-index,

last_line LIKE sy-index.

CASE tab_dynpro-activetab.

WHEN 'TAB_TCODES'.

top_line = tc_tcodes-top_line.

DESCRIBE TABLE bdc_tcodes LINES last_line.

WHEN 'TAB_LIST'.

top_line = tc_dynpro-top_line.

DESCRIBE TABLE bdc_dynpro LINES last_line.

WHEN 'TAB_PROTO'.

top_line = tc_protocol-top_line.

DESCRIBE TABLE bdc_protocol LINES last_line.

ENDCASE.

CALL FUNCTION 'SCROLLING_IN_TABLE'

EXPORTING

entry_act = top_line

entry_from = 1

entry_to = last_line

ok_code = main_okcode

last_page_full = ' '

overlapping = ' '

loops = loopc

IMPORTING

entries_sum = entries

entry_new = new_line

pages_sum = total_pages

page_new = new_page

EXCEPTIONS

no_entry_or_page_act = 01

no_entry_to = 02

no_ok_code_or_page_go = 03.

CHECK sy-subrc = 0.

CASE tab_dynpro-activetab.

WHEN 'TAB_TCODES'.

tc_tcodes-top_line = new_line.

WHEN 'TAB_LIST'.

tc_dynpro-top_line = new_line.

WHEN 'TAB_PROTO'.

tc_protocol-top_line = new_line.

ENDCASE.

ENDFORM. "scrolling

*&----


*

*& Module d0700_init OUTPUT

*&----


*

MODULE d0700_init OUTPUT.

CLEAR d0700_fcode.

SET TITLEBAR 'QUEUE_DUMP' WITH apqi-groupid.

SET PF-STATUS 'PF_QUEUE'.

IF q-tcode_index IS INITIAL.

IF NOT tcode_index_apqd IS INITIAL.

q-tcode_index = tcode_index_apqd.

ELSE.

READ TABLE all_bdc_tcodes INTO q-wa INDEX 1.

q-tcode_index = q-wa-index.

ENDIF.

ENDIF.

  • check for unicode; how many byte's a character?

DESCRIBE FIELD q-c LENGTH q-uc_bytes IN BYTE MODE.

  • read all blocks (dynpros) of the currently selected transaction

SELECT * FROM apqd INTO TABLE it_apqd

WHERE qid = queue_id AND trans = q-tcode_index.

ENDMODULE. " d0700_init OUTPUT

*&----


*

*& Module d0700_fcode INPUT

*&----


*

MODULE d0700_fcode INPUT.

CASE d0700_fcode.

WHEN 'BACK'.

CLEAR q-tcode_index.

LEAVE TO SCREEN 0.

WHEN 'END'.

CLEAR q-tcode_index.

LEAVE PROGRAM.

WHEN 'TOGGLE'.

IF q-show_hex IS INITIAL.

q-show_hex = 'X'.

ELSE.

CLEAR q-show_hex.

ENDIF.

WHEN 'APQI'.

CALL SCREEN '0701'.

WHEN OTHERS.

"nop

ENDCASE.

ENDMODULE. " ok_700 INPUT

*&----


*

*& Module exit_700 INPUT

*&----


*

MODULE d0700_exit INPUT.

LEAVE TO SCREEN 0.

ENDMODULE. " exit_700 INPUT

*&----


*

*& Module set_status_icon OUTPUT

*&----


*

MODULE set_status_icon OUTPUT.

DATA: icon_name(4),

icon_info(32).

CASE all_bdc_tcodes-status.

WHEN 'F'.

icon_name = icon_status_ok.

icon_info = 'verarbeitet'(002).

WHEN 'E'.

icon_name = icon_status_critical.

icon_info = 'fehlerhaft'(001).

WHEN 'D'.

icon_name = icon_delete.

icon_info = 'gelöscht'(005).

WHEN ' ' OR 'B'.

icon_name = icon_create.

icon_info = 'neu'(034).

WHEN OTHERS.

icon_name = all_bdc_tcodes-status.

icon_info = '???'.

ENDCASE.

CALL FUNCTION 'ICON_CREATE'

EXPORTING

name = icon_name

info = icon_info

IMPORTING

RESULT = status_icon

EXCEPTIONS

OTHERS = 1.

IF sy-subrc <> 0.

status_icon = icon_name.

ENDIF.

IF all_bdc_tcodes-index = q-tcode_index.

LOOP AT SCREEN.

screen-intensified = 1.

MODIFY SCREEN.

ENDLOOP.

ENDIF.

ENDMODULE. " set_status_icon OUTPUT

*&----


*

*& Module d0700_get_cursor INPUT

*&----


*

MODULE d0700_get_cursor INPUT.

GET CURSOR FIELD q-c_field LINE q-c_line AREA q-c_area.

IF sy-subrc = 0.

CHECK q-c_area = 'TC_Q_TCODES'.

CHECK q-c_line > 0.

q-itab_index = tc_q_tcodes-top_line + q-c_line - 1.

READ TABLE all_bdc_tcodes INTO q-wa INDEX q-itab_index.

q-tcode_index = q-wa-index.

ENDIF.

ENDMODULE. " d0700_get_cursor INPUT

*&----


*

*& Module d0700_control_init OUTPUT

*&----


*

MODULE d0700_control_init OUTPUT.

CHECK q-control_init = 'X'.

  • create custom container and dynamic document

CREATE OBJECT cust

EXPORTING

container_name = 'CUSTOM_CONTAINER'

dynnr = '0700'

repid = 'RSBDC_ANALYSE'

  • lifetime = cntl_lifetime_dynpro

EXCEPTIONS

OTHERS = 1.

CREATE OBJECT dd

EXPORTING

background_color = cl_dd_area=>col_textarea.

CLEAR q-control_init.

ENDMODULE. " d0700_control_init OUTPUT

*&----


*

*& Module d0700_display OUTPUT

*&----


*

MODULE d0700_display OUTPUT.

CALL METHOD dd->initialize_document

EXPORTING

background_color = cl_dd_area=>col_textarea.

REFRESH it_blocks.

  • loop at all apqd blocks for the current transaction and built up the

  • dynamic document for each block

LOOP AT it_apqd.

PERFORM build_queue_dd.

ENDLOOP.

CALL METHOD dd->merge_document.

CALL METHOD dd->display_document

EXPORTING

parent = cust

reuse_control = q-reuse_control

EXCEPTIONS

html_display_error = 1.

  • if the HTML control for the DD is already created, we can re-use it.

IF q-reuse_control IS INITIAL.

q-reuse_control = 'X'.

ENDIF.

ENDMODULE. " d0700_display OUTPUT

*&----


*

*& Form build_queue_dd

*&----


*

FORM build_queue_dd.

DATA: off LIKE sy-index.

  • write the most important apqd header fields

dd->new_line( ).

WRITE it_apqd-qid TO c.

CONCATENATE 'Queue-ID:'(030) c INTO t SEPARATED BY space.

dd->add_text( text = t ).

dd->new_line( ).

WRITE it_apqd-trans TO c.

CONCATENATE 'Transaktion:'(031) c INTO t SEPARATED BY space.

dd->add_text( text = t ).

dd->new_line( ).

WRITE it_apqd-block TO c.

CONCATENATE 'Block:'(032) c INTO t SEPARATED BY space.

dd->add_text( text = t

sap_color = cl_dd_table_area=>list_positive ).

dd->new_line( ).

WRITE it_apqd-varlen TO c.

CONCATENATE 'VARDATA-Länge:'(033) c INTO t SEPARATED BY space.

dd->add_text( text = t ).

dd->new_line( ).

  • now add a DD table to it_blocks for the current APQD block

CLEAR b_wa.

REFRESH it_cx.

CALL METHOD dd->add_table

EXPORTING

no_of_columns = nr_cols

cell_background_transparent = space

border = '0'

width = '100%'

IMPORTING

tablearea = b_wa-dta

table = b_wa-dt

EXCEPTIONS

OTHERS = 1.

APPEND b_wa TO it_blocks.

  • prepare ascii/hex table

DO it_apqd-varlen TIMES.

off = sy-index - 1.

ASSIGN it_apqd-vardata+off(1) TO .

WRITE cx-hex TO cx-xtoc.

APPEND cx TO it_cx.

ENDDO.

  • write apqd-vardata (as prepared in it_cx ) to the DD list

PERFORM vardata_lines.

ENDFORM. " build_queue_dd

*&----


*

*& Form vardata_lines

*&----


*

FORM vardata_lines.

count-start = 0.

count-rest = it_apqd-varlen.

IF it_apqd-varlen < nr_cols.

count-part = it_apqd-varlen.

ELSE.

count-part = nr_cols.

ENDIF.

DO.

cspan = nr_cols - count-part.

  • 1. the ASCII - Value

b_wa-dta->new_row( sap_color = cl_dd_table_area=>list_heading ).

DO count-part TIMES.

count-index = count-start + sy-index.

READ TABLE it_cx INTO cx INDEX count-index.

IF NOT cx-hex IS INITIAL.

t = cx-char.

b_wa-dta->add_text( text = t ).

ELSE.

t = space.

b_wa-dta->add_text( text = t

sap_color = cl_dd_table_area=>list_negative ).

ENDIF.

ENDDO.

IF count-rest < nr_cols.

t = space.

DO cspan TIMES.

b_wa-dta->add_text( text = t

sap_color =

cl_dd_table_area=>list_background ).

ENDDO.

ENDIF.

IF q-show_hex = 'X'.

  • 2. at least one Byte hex-code for non-unicode systems

b_wa-dta->new_row( sap_style = cl_dd_table_area=>list_normal ).

PERFORM hex_line USING cx-xtoc+0(1).

b_wa-dta->new_row( sap_style = cl_dd_table_area=>list_normal ).

PERFORM hex_line USING cx-xtoc+1(1).

  • 3. two-byte unicode:

IF ( q-uc_bytes = 2 OR q-uc_bytes = 4 ).

b_wa-dta->new_row( sap_style = cl_dd_table_area=>list_normal ).

PERFORM hex_line USING cx-xtoc+2(1).

b_wa-dta->new_row( sap_style = cl_dd_table_area=>list_normal ).

PERFORM hex_line USING cx-xtoc+3(1).

ENDIF.

  • 3. four-byte unicode:

IF ( q-uc_bytes = 4 ).

b_wa-dta->new_row( sap_style = cl_dd_table_area=>list_normal ).

PERFORM hex_line USING cx-xtoc+4(1).

b_wa-dta->new_row( sap_style = cl_dd_table_area=>list_normal ).

PERFORM hex_line USING cx-xtoc+5(1).

b_wa-dta->new_row( sap_style = cl_dd_table_area=>list_normal ).

PERFORM hex_line USING cx-xtoc+6(1).

b_wa-dta->new_row( sap_style = cl_dd_table_area=>list_normal ).

PERFORM hex_line USING cx-xtoc+7(1).

ENDIF.

ENDIF.

b_wa-dta->new_row( sap_style = cl_dd_table_area=>list_normal ).

  • calculate new counter values for next line(s)

count-rest = count-rest - nr_cols.

IF count-rest < 0.

EXIT.

ELSE.

count-start = count-start + nr_cols.

IF count-rest < nr_cols.

count-part = count-rest.

ELSE.

count-part = nr_cols.

ENDIF.

ENDIF.

ENDDO.

ENDFORM. " vardata_lines

*&----


*

*& Form hex_line

*&----


*

  • -->P_T text

*----


*

FORM hex_line USING p_t.

DO count-part TIMES.

count-index = count-start + sy-index.

READ TABLE it_cx INTO cx INDEX count-index.

t = p_t.

b_wa-dta->add_text( text = t ).

ENDDO.

IF count-rest < nr_cols.

DO cspan TIMES.

t = space.

b_wa-dta->add_text( text = t ).

ENDDO.

ENDIF.

ENDFORM. " hex_line

*&----


*

*& Module d0701_init OUTPUT

*&----


*

MODULE d0701_init OUTPUT.

DATA:

extab TYPE STANDARD TABLE OF fcode.

REFRESH extab.

APPEND 'TOGGLE' TO extab.

APPEND 'APQI' TO extab.

SET PF-STATUS 'PF_QUEUE' EXCLUDING extab.

SET TITLEBAR 'APQI_DUMP' WITH apqi-groupid.

ENDMODULE. " d0701_init OUTPUT

*&----


*

*& Module d0701_fcode INPUT

*&----


*

MODULE d0701_fcode INPUT.

CASE d0701_fcode.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'END'.

LEAVE PROGRAM.

WHEN 'UNLOCK'.

PERFORM session_unlock.

WHEN 'TOGGLE_KEEP'.

PERFORM session_toggle_keep_flag.

WHEN OTHERS.

"nop

ENDCASE.

ENDMODULE. " d0701_fcode INPUT

*&----


*

*& Form session_unlock

*&----


*

FORM session_unlock.

DATA: user LIKE sy-uname.

AUTHORITY-CHECK OBJECT 'S_BDC_MONI'

ID 'BDCAKTI' FIELD 'LOCK'

ID 'BDCGROUPID' FIELD apqi-groupid.

IF sy-subrc <> 0. MESSAGE i394 WITH apqi-groupid. EXIT. ENDIF.

CALL FUNCTION 'ENQUEUE_BDC_QID'

EXPORTING

datatyp = 'BDC'

groupid = apqi-groupid

qid = apqi-qid

EXCEPTIONS

foreign_lock = 1

system_failure = 99.

IF sy-subrc <> 0.

CASE sy-subrc.

WHEN 1.

user = sy-msgv1.

MESSAGE i322 WITH apqi-groupid apqi-qid user.

WHEN 99. MESSAGE i353 WITH apqi-groupid.

ENDCASE.

EXIT.

ENDIF.

CLEAR apqi-startdate. UPDATE apqi. COMMIT WORK.

CALL FUNCTION 'DEQUEUE_BDC_QID'

EXPORTING

datatyp = 'BDC'

groupid = apqi-groupid

qid = apqi-qid.

  • tell SM35 to reload table APQI

EXPORT reload_apqi TO MEMORY ID 'RELOAD_APQI'.

ENDFORM. " session_unlock

*&----


*

*& Form session_toggle_keep_flag

*&----


*

FORM session_toggle_keep_flag.

DATA: user LIKE sy-uname.

  • since setting or deleting the apqi-qerase flag can be considered of

  • being equal to deleting a session, we check for the corresponding

  • authorization. There's no special 'KEEP' activity for S_BDC_MONI

AUTHORITY-CHECK OBJECT 'S_BDC_MONI'

ID 'BDCAKTI' FIELD 'DELE'

ID 'BDCGROUPID' FIELD apqi-groupid.

IF sy-subrc <> 0. MESSAGE i395 WITH apqi-groupid. EXIT. ENDIF.

CALL FUNCTION 'ENQUEUE_BDC_QID'

EXPORTING

datatyp = 'BDC'

groupid = apqi-groupid

qid = apqi-qid

EXCEPTIONS

foreign_lock = 1

system_failure = 99.

IF sy-subrc <> 0.

CASE sy-subrc.

WHEN 1.

user = sy-msgv1.

MESSAGE i322 WITH apqi-groupid apqi-qid user.

WHEN 99.

MESSAGE i353 WITH apqi-groupid.

ENDCASE.

EXIT.

ENDIF.

IF apqi-qerase = 'X'.

CLEAR apqi-qerase.

ELSE.

apqi-qerase = 'X'.

ENDIF.

UPDATE apqi. COMMIT WORK.

CALL FUNCTION 'DEQUEUE_BDC_QID'

EXPORTING

datatyp = 'BDC'

groupid = apqi-groupid

qid = apqi-qid.

  • tell SM35 to reload table APQI

EXPORT reload_apqi TO MEMORY ID 'RELOAD_APQI'.

ENDFORM. " session_toggle_keep_flag

*&----


*

*& Module d0702_init OUTPUT

*&----


*

MODULE d0702_init OUTPUT.

IF apqi-startdate IS INITIAL.

LOOP AT SCREEN.

IF screen-name = 'PB_UNLOCK'.

screen-invisible = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

ENDMODULE. " d0702_init OUTPUT

*&----


*

*& Module MARK_TCODE OUTPUT

*&----


*

MODULE mark_tcode OUTPUT.

IF ( ( tcode_index_apqd = 0 )

AND ( bdc_tcodes-index = 1st_bdc_tcode_index ) )

OR ( bdc_tcodes-index = tcode_index_apqd ).

LOOP AT SCREEN.

screen-intensified = 1. MODIFY SCREEN.

ENDLOOP.

ENDIF.

ENDMODULE. " mark_tcode output

*----


*

  • FORM count_dynpros

  • Count dynpros for a selected transaction

*----


*

FORM count_dynpros USING tcnt.

CLEAR it_apqd. REFRESH it_apqd.

SELECT * FROM apqd INTO TABLE it_apqd

WHERE qid = queue_id AND trans = tcnt.

CLEAR dynpro_cnt.

LOOP AT it_apqd.

IF it_apqd-vardata(1) = 'M'. "it's a message header

dynpro_cnt = dynpro_cnt + 1.

ENDIF.

ENDLOOP.

ENDFORM. "count_dynpros

*----


*

  • FORM recalculate_counters

  • recalculate dynpro counters

*----


*

FORM recalculate_counters.

CLEAR: apqdcnt-msgcntb,

apqdcnt-msgcnte,

apqdcnt-msgcnto,

apqdcnt-msgcntf,

apqdcnt-msgcntd,

apqdcnt-msgcnt,

apqdcnt-msgcntx,

apqdcnt-msgcntp.

LOOP AT all_bdc_tcodes.

PERFORM count_dynpros USING all_bdc_tcodes-index.

ADD dynpro_cnt TO apqdcnt-msgcnt.

CASE all_bdc_tcodes-status.

WHEN 'D' OR 'G'.

ADD dynpro_cnt TO apqdcnt-msgcntd.

WHEN 'F'.

ADD dynpro_cnt TO apqdcnt-msgcntf.

WHEN 'E'.

ADD dynpro_cnt TO apqdcnt-msgcnte.

WHEN 'B'.

ADD dynpro_cnt TO apqdcnt-msgcntb.

ENDCASE.

ENDLOOP.

apqdcnt-msgcnto = apqdcnt-msgcntb

+ apqdcnt-msgcnte.

apqdcnt-msgcntd = apqdcnt-msgcnt

- apqdcnt-msgcntf

- apqdcnt-msgcnte

- apqdcnt-msgcntb.

apqdcnt-msgcntp = apqi-putblock

- apqi-puttrans.

apqdcnt-msgcntx = apqdcnt-msgcntp

- apqdcnt-msgcnt.

show_dynpro_cnt = 'X'.

ENDFORM. "recalculate_counters

*&----


*

*& Form download

*----


*

FORM download .

REFRESH lt_string.

LOOP AT bdclm.

CONCATENATE bdclm-tcnt bdclm-longtext INTO wa_string SEPARATED BY '|'.

APPEND wa_string TO lt_string.

ENDLOOP.

filename = 'H:Errorlog.xls'.

CALL METHOD cl_gui_frontend_services=>gui_download

EXPORTING

filename = filename

filetype = 'DAT'

CHANGING

data_tab = lt_string

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

not_supported_by_gui = 22

error_no_gui = 23

OTHERS = 24.

IF sy-subrc NE 0.

MESSAGE e000(vz) WITH 'Error while'

'downloading'

'BDC log to'

filename.

ELSE.

MESSAGE s000(vz) WITH 'Log'

'downloaded'

'to'

filename.

ENDIF.

Former Member
0 Kudos

i will give some exact steps in bdc session method

ex : think this is flat file contains some records

venodr_name po numb

shreeshail 1020

sam 1021

steps :

1 first declare the internal table and bdcdata

DATA IT LIKE LFA1 OCCURS 0 WITH HEADER LINE

DATA BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE .

CALL FUNCTION UPLOAD

exp

it-data = it .

2

CALL FUNCTION 'BDC_OPEN_GROUP' .

here u pass some 4 parameters :

USER NAME

SESSION NAME

LOCK DATE

KEEP

3

LOOP AT IT /

REFRESH BDCDATA .

perform bdc_dybmaic_program .

go transaction SHDB TO CREATE BDC RECORDS

CALL FUNCTION BDC_INSERT .

here u can pass 2 parameters :

transaction code : 'MK01' .

bdctaa : BDCDATA

CALL FUNCTION BDC_CLOSE_GROUP .

FORM BDC_DYNAMIC_PROGRAM .

NOTE: if error occurs

u can create another internal table like BDCMSGCOLL

Former Member
0 Kudos

Hi Ranjita,

Execute the errors in session again in the foreground mode and give the correct values to process the records

Regards

Arun

S0025444845
Active Participant
0 Kudos

Hi Ranjeetha,

Can you please tell me how you have captured error log from output and displayed.

Regards,

Sudha

Former Member
0 Kudos

i am getting a runtime error after executing this bdc seesion program

exception condition "upload_ole" raised

the following program code is given below:----->

report ZBDC_SESSION3

no standard page heading line-size 255.

*include bdcrecx1.

TYPES : BEGIN OF TY_MARA,

        MATNR TYPE MATNR,

        MBRSH TYPE MBRSH,

        MTART TYPE MTART,

        MAKTX TYPE MAKTX,

        MEINS TYPE MEINS,

END OF TY_MARA.

DATA : IT_MARA TYPE STANDARD TABLE OF TY_MARA,

WA_MARA TYPE TY_MARA.

DATA : IT_EXCEL TYPE STANDARD TABLE OF ALSMEX_TABLINE,

WA_EXCEL TYPE ALSMEX_TABLINE.

DATA : BDCDATA TYPE BDCDATA OCCURS 0 WITH HEADER LINE.

start-of-selection.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

  EXPORTING

    FILENAME                      = 'C:\Documents and Settings\Administrator\Desktop\BDC_SESSION3.XLS'

I_BEGIN_COL                   = 1

I_BEGIN_ROW                   = 2

    I_END_COL                     = 5

    I_END_ROW                     = 3

  TABLES

    INTERN                        = IT_EXCEL

* 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.

  1. ENDIF.

*perform open_group.

LOOP AT IT_EXCEL INTO WA_EXCEL.

CASE WA_EXCEL-COL.

WHEN '0001'.

      WA_MARA-MATNR = WA_EXCEL-VALUE.

WHEN '0002'.

      WA_MARA-MBRSH = WA_EXCEL-VALUE.

WHEN '0003'.

      WA_MARA-MTART = WA_EXCEL-VALUE.

WHEN '0004'.

      WA_MARA-MAKTX = WA_EXCEL-VALUE.

WHEN '0005'.

      WA_MARA-MEINS = WA_EXCEL-VALUE.

AT END OF ROW.

    APPEND WA_MARA TO IT_MARA.

  1. ENDAT.
  2. ENDCASE.

  1. ENDLOOP.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

    CLIENT                    = SY-MANDT

*   DEST                      = FILLER8

    GROUP                     = 'ZKUMAR'

*   HOLDDATE                  = FILLER8

    KEEP                      = 'X'

    USER                      = SY-UNAME

*   RECORD                    = FILLER1

    PROG                      = SY-CPROG

*   DCPFM                     = '%'

*   DATFM                     = '%'

* IMPORTING

*   QID                       =

* EXCEPTIONS

* CLIENT_INVALID            = 1

* DESTINATION_INVALID       = 2

* GROUP_INVALID             = 3

* GROUP_IS_LOCKED           = 4

* HOLDDATE_INVALID          = 5

* INTERNAL_ERROR            = 6

* QUEUE_ERROR               = 7

*   RUNNING                   = 8

*   SYSTEM_LOCK_ERROR         = 9

* USER_INVALID              = 10

*   OTHERS                    = 11

          .

IF SY-SUBRC <> 0.

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

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

  1. ENDIF.

LOOP AT IT_MARA INTO WA_MARA.

  CLEAR BDCDATA.

  REFRESH BDCDATA.

performbdc_dynpro using 'SAPLMGMM' '0060'.

performbdc_field using 'BDC_CURSOR'

'RMMG1-MTART'.

performbdc_field using 'BDC_OKCODE'

'/00'.

performbdc_field using 'RMMG1-MATNR'

WA_MARA-MATNR.

"'MIRINDA'.

performbdc_field using 'RMMG1-MBRSH'

WA_MARA-MBRSH.

"'F'.

performbdc_field using 'RMMG1-MTART'

WA_MARA-MTART.

"'FGTR'.

performbdc_dynpro using 'SAPLMGMM' '0070'.

performbdc_field using 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(01)'.

performbdc_field using 'BDC_OKCODE'

                              '=ENTR'.

performbdc_field using 'MSICHTAUSW-KZSEL(01)'

                              'X'.

performbdc_dynpro using 'SAPLMGMM' '4004'.

performbdc_field using 'BDC_OKCODE'

                              '=BU'.

performbdc_field using 'MAKT-MAKTX'

WA_MARA-MAKTX.

"' COLD DRINK'.

performbdc_field using 'BDC_CURSOR'

'MARA-MEINS'.

performbdc_field using 'MARA-MEINS'

WA_MARA-MEINS.

"'L'.

performbdc_field using 'MARA-MTPOS_MARA'

                              'NORM'.

*perform bdc_transaction using 'MM01'.

*perform close_group.

CALL FUNCTION 'BDC_INSERT'

  EXPORTING

    TCODE                  = 'MM01'

*   POST_LOCAL             = NOVBLOCAL

*   PRINTING               = NOPRINT

*   SIMUBATCH              = ' '

*   CTUPARAMS              = ' '

  TABLES

    DYNPROTAB              = BDCDATA

* EXCEPTIONS

* INTERNAL_ERROR         = 1

*   NOT_OPEN               = 2

* QUEUE_ERROR            = 3

* TCODE_INVALID          = 4

* PRINTING_INVALID       = 5

* POSTING_INVALID        = 6

*   OTHERS                 = 7

          .

IF SY-SUBRC <> 0.

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

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

  1. ENDIF.
  2. ENDLOOP.

CALL FUNCTION 'BDC_CLOSE_GROUP'

* EXCEPTIONS

*   NOT_OPEN          = 1

* QUEUE_ERROR       = 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.

  1. ENDIF.

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

*        Start new screen                                              *

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

FORM BDC_DYNPRO USING PROGRAM DYNPRO.

  CLEAR BDCDATA.

BDCDATA-PROGRAM  = PROGRAM.

BDCDATA-DYNPRO   = DYNPRO.

  BDCDATA-DYNBEGIN = 'X'.

  APPEND BDCDATA.

  1. ENDFORM.

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

*        Insert field *

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

FORM BDC_FIELD USING FNAM FVAL.

*  IF FVAL <> NODATA.

    CLEAR BDCDATA.

    BDCDATA-FNAM = FNAM.

    BDCDATA-FVAL = FVAL.

    APPEND BDCDATA.

*  ENDIF.

  1. ENDFORM.

0 Kudos

Hi

Use below code which gets the errors and success records. You change the code as your requirement.

REPORT  ybdc_errlog.

DATA: w_ref_alv TYPE REF TO cl_salv_table.

DATA:
  BEGIN OF mttab  OCCURS 4,
   off(02) TYPE n,
   len(02) TYPE n,
   text(99),
END OF mttab.

DATA:
  BEGIN OF par,
   len(02) TYPE n,
   text(254),
END OF par.

FIELD-SYMBOLS:
              <mtxt>,
              <vtxt>.

DATA save_mpar TYPE bdc_mpar.
DATA:
  digits(10) TYPE c VALUE '0123456789',
  mtext(124) TYPE c,
  mtext1(124) TYPE c,
  mtext2(273) TYPE c,
  do_condense TYPE c,
  mtvaroff TYPE i,
  showtyp(05) TYPE c,
  lmapn(12) TYPE c,
  date1  TYPE d,
  linct0      LIKE sy-linct,
   parcnt  TYPE i,
  sp_len  TYPE i,
  charcnt TYPE i,
  wcnt TYPE i,
  mparcnt TYPE i,
  qfound(04) TYPE n,
  x(1) VALUE 'X'.

DATA: BEGIN OF logtable OCCURS 50,
        enterdate LIKE btctle-enterdate,
        entertime LIKE btctle-entertime,
        logmessage(400) TYPE c,
      END OF logtable.

DATA lm TYPE bdclm.

DATA BEGIN OF bdclm OCCURS 0.
        INCLUDE STRUCTURE bdclm.
DATA: counter TYPE i,
      longtext TYPE bdc_mpar,
      isdetail(1) TYPE c,
      END OF bdclm .

DATA:  logtab_temse TYPE STANDARD TABLE OF apql .
DATA: wa_log TYPE apql,
      wa_ld  TYPE ztt_bdc,
      w_bdcld  TYPE ztt_bdc,
      logname(80),
      bdcld TYPE STANDARD TABLE OF ztt_bdc,
      selected_protocol TYPE i.

SELECT * FROM apql INTO TABLE logtab_temse
           WHERE qid = '10120911353254644605'.

LOOP AT logtab_temse INTO wa_log.
  CLEAR wa_ld.
  wa_ld-temseid = wa_log-temseid.
  wa_ld-lmand   = wa_log-mandant.
  wa_ld-edate   = wa_log-credate.
  wa_ld-etime   = wa_log-cretime.
  wa_ld-luser   = wa_log-creator.
  wa_ld-grpn    = wa_log-groupid.
  wa_ld-quid    = wa_log-qid.
  wa_ld-local_host = wa_log-destsys(8).
  APPEND wa_ld TO bdcld.
ENDLOOP.

*  now bdcld contains the log files for the given qid
SORT bdcld BY edate DESCENDING etime DESCENDING.
DESCRIBE TABLE bdcld LINES selected_protocol.

IF selected_protocol > 0.
  READ TABLE bdcld INTO w_bdcld  INDEX 1.
  logname = w_bdcld-logname.

  PERFORM read_bdc_log_plain
      TABLES logtable
      USING  w_bdcld-temseid w_bdcld-lmand.

  PERFORM extend_message_texts.
ENDIF.

IF  bdclm IS NOT INITIAL.

  TRY.
      CALL METHOD cl_salv_table=>factory
        IMPORTING
          r_salv_table = w_ref_alv
        CHANGING
          t_table      = bdclm[].
    CATCH cx_salv_msg .
  ENDTRY.

  w_ref_alv->display( ).

ENDIF.

*&---------------------------------------------------------------------*
*&      Form  extend_message_texts
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM extend_message_texts.

  LOOP AT bdclm .
    lm = bdclm.
    save_mpar = bdclm-mpar.
    PERFORM get_text.
    bdclm-longtext = mtext.
    bdclm-mpar = save_mpar.
    MODIFY bdclm.
  ENDLOOP.
ENDFORM.                    "extend_message_texts

*&---------------------------------------------------------------------*
*&      Form  get_text
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM get_text.
*
*** Aufbereiten des Messagetextes
*
  TABLES t100.
  DATA: shiftln TYPE i,
        vartcnt TYPE i,
        fdpos LIKE sy-fdpos.

  IF bdclm-mparcnt CN digits.
    bdclm-mparcnt = 0.
  ENDIF.

  SELECT SINGLE * FROM t100
   WHERE sprsl = sy-langu
   AND  arbgb  = bdclm-mid
   AND  msgnr  = bdclm-mnr.
*
  IF sy-subrc EQ 0.
    CLEAR: mtext,
           parcnt,
           mparcnt,
           charcnt,
           wcnt,
*             mt,
           sp_len,
           sy-fdpos.
*
    MOVE bdclm-mparcnt TO mparcnt.
*
    IF t100-text CA '$&'.
      MOVE t100-text TO mtext1.
    ELSE.
      MOVE t100-text TO mtext.
      EXIT.
    ENDIF.

    CLEAR shiftln.
    DO mparcnt TIMES.
      MOVE bdclm-mpar TO par.
      IF par-len CN digits OR par-len EQ 0.
        par-len  = 1.
        par-text = ' '.
        shiftln  = 2.
      ELSE.
        shiftln = par-len + 2.
      ENDIF.
      WRITE par-text TO   mttab-text(par-len).
      MOVE par-len  TO mttab-len.
      MOVE mparcnt  TO mttab-off.
      APPEND mttab.
      SHIFT bdclm-mpar BY shiftln PLACES.
    ENDDO.
*
    mtext2 = mtext1.
    IF bdclm-mid EQ  '00' AND    " sonderbehandlung s00368
       bdclm-mnr EQ '368' AND
       bdclm-mart EQ 'S'.
      CLEAR mtext2.
      CLEAR mttab.
      READ TABLE mttab INDEX 1.
      WRITE mttab-text TO mtext2+0(mttab-len).
      CLEAR mttab.
      READ TABLE mttab INDEX 2.
      WRITE mttab-text TO mtext2+35(mttab-len).
      mtext = mtext2.
      EXIT.
    ENDIF.

    do_condense = x.
    CLEAR:  vartcnt, mtvaroff.
    WHILE vartcnt LE 3.
      vartcnt = vartcnt + 1.
      IF mtext1 CA '$&'.
        parcnt = parcnt + 1.
        IF sy-fdpos GT 0.
          fdpos = sy-fdpos - 1.
        ELSE.
          fdpos = sy-fdpos.
        ENDIF.
        SHIFT mtext1 BY sy-fdpos PLACES.
        IF mtext1(1) EQ '&'.
          SHIFT mtext1 BY 1 PLACES.
          CASE mtext1(1).
            WHEN ' '.                              "'& '
              PERFORM replace_var USING '& ' parcnt fdpos.
            WHEN '$'.                              "'&&'
              PERFORM replace_var USING '&&' 0      fdpos.
            WHEN '1'.                                       "'&1'
              PERFORM replace_var USING '&1' 1      fdpos.
            WHEN '2'.                                       "'&2'
              PERFORM replace_var USING '&2' 2      fdpos.
            WHEN '3'.                                       "'&3'
              PERFORM replace_var USING '&3' 3      fdpos.
            WHEN '4'.                                       "'&4'
              PERFORM replace_var USING '&4' 4      fdpos.
            WHEN OTHERS.                           "'&'
              PERFORM replace_var USING '&<' parcnt fdpos.
          ENDCASE.
        ENDIF.
        IF mtext1(1) EQ '$'.
          SHIFT mtext1 BY 1 PLACES.
          CASE mtext1(1).
            WHEN ' '.                              "'$ '
              PERFORM replace_var USING '$ ' parcnt  fdpos.
            WHEN '$'.                              "'$$'
              PERFORM replace_var USING '$$' 0       fdpos.
            WHEN '1'.                                       "'$1'
              PERFORM replace_var USING '$1' 1       fdpos.
            WHEN '2'.                                       "'$2'
              PERFORM replace_var USING '$2' 2       fdpos.
            WHEN '3'.                                       "'$3'
              PERFORM replace_var USING '$3' 3       fdpos.
            WHEN '4'.                                       "'$4'
              PERFORM replace_var USING '$4' 4       fdpos.
            WHEN OTHERS.                           "'$'
              PERFORM replace_var USING '$<' parcnt  fdpos.
          ENDCASE.
        ENDIF.
      ENDIF.
    ENDWHILE.
*
    IF mtext2 CA '%%D%%'.
      REPLACE '%%D%%' WITH '$' INTO mtext2.
    ENDIF.
    IF mtext2 CA '%%A%%'.
      REPLACE '%%A%%' WITH '&' INTO mtext2.
    ENDIF.
    IF do_condense EQ space.
      mtext = mtext2.
    ELSE.
      CONDENSE mtext2 .
      mtext = mtext2.
    ENDIF.
  ELSE.
    mtext = '???????????????????????????????????????????????????'.
  ENDIF.
*
ENDFORM.                                                    " get_text1
*&---------------------------------------------------------------------*
*&      Form  READ_BDC_LOG_PLAIN
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_LOGTABLE  text
*      -->P_BDCLD_TEMSEID  text
*      -->P_BDCLD_LMAND  text
*----------------------------------------------------------------------*
FORM read_bdc_log_plain  TABLES   log_table

                         USING    p_bdcld_temseid
                                  p_bdcld_lmand.

  DATA: charcp LIKE rststype-charco VALUE '0000'.

  FREE log_table.

  CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
    EXPORTING
      authority     = ' '
      client        = sy-mandt
      name          = p_bdcld_temseid
    IMPORTING
      charco        = charcp
    EXCEPTIONS
      fb_error      = 1
      fb_rsts_other = 2
      no_object     = 3
      no_permission = 4
      OTHERS        = 5.

  IF cl_abap_char_utilities=>charsize > 1.
    charcp = '0000'.
  ENDIF.

  CALL FUNCTION 'RSTS_OPEN_RLC'
    EXPORTING
      name           = p_bdcld_temseid
      client         = sy-mandt
      authority      = 'BATCH'
      prom           = 'I'
      rectyp         = 'VNL----'
      charco         = charcp
    EXCEPTIONS
      fb_call_handle = 4
      fb_error       = 8
      fb_rsts_noconv = 12
      fb_rsts_other  = 16
      no_object      = 20
      OTHERS         = 24.

  IF sy-subrc > 0.
    EXIT.
  ENDIF.

  CALL FUNCTION 'RSTS_READ'
    TABLES
      datatab        = log_table
    EXCEPTIONS
      fb_call_handle = 4
      fb_error       = 8
      fb_rsts_noconv = 12
      fb_rsts_other  = 16
      OTHERS         = 16.

  IF sy-subrc > 0.
    EXIT.
  ENDIF.

  CALL FUNCTION 'RSTS_CLOSE'
    EXCEPTIONS
      OTHERS = 4.

  IF sy-subrc > 0.
    EXIT.
  ENDIF.

  CLEAR bdclm[].
  LOOP AT logtable.
    CLEAR bdclm.
    bdclm-indate  = logtable-enterdate.
    bdclm-intime  = logtable-entertime.
    bdclm+14(352) = logtable-logmessage.
    IF bdclm-mcnt > 0.
      bdclm-mcnt = bdclm-mcnt - 1.
    ENDIF.

    IF bdclm-mid EQ '00'.
      IF   ( bdclm-mnr EQ '162' )
        OR ( bdclm-mnr EQ '368' ).
        bdclm-isdetail = 'X'.
      ENDIF.
    ENDIF.

    APPEND bdclm.
  ENDLOOP.

ENDFORM.                    " READ_BDC_LOG_PLAIN

*&---------------------------------------------------------------------*
*&      Form  replace_var
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->VARK       text
*      -->VARI       text
*      -->VARPOS     text
*----------------------------------------------------------------------*
FORM replace_var USING vark vari varpos.

  DATA: var(02),
        var1,
        moff TYPE i.
*
  CLEAR: mttab , moff.
  var = vark.
  SHIFT var BY 1 PLACES.
  CASE var.
    WHEN ' '.                              "'& '
      READ TABLE mttab INDEX vari.
      IF sy-subrc EQ 0.
        moff = varpos + mtvaroff.
        ASSIGN mtext2+moff(*) TO <mtxt>.
        ASSIGN mttab-text(mttab-len) TO <vtxt>.
        var1 = vark.
        REPLACE var1 WITH <vtxt>     INTO <mtxt>.
        mtvaroff = mttab-len.
      ELSE.
        IF vari GT mparcnt.
          moff = varpos + mtvaroff.
          ASSIGN mtext2+moff(*) TO <mtxt>.
          REPLACE vark WITH '  ' INTO <mtxt>.
          mtvaroff = 2.
        ELSE.
          moff = varpos + mtvaroff.
          ASSIGN mtext2+moff(*) TO <mtxt>.
          REPLACE vark WITH '%%Z%%' INTO <mtxt>.
          mtvaroff = 7.
        ENDIF.
      ENDIF.
    WHEN '$'.                              "'&&'
      moff = varpos + mtvaroff.
      ASSIGN mtext2+moff(*) TO <mtxt>.
      REPLACE vark WITH '%%D%%' INTO <mtxt>.
      mtvaroff = 7.
    WHEN '&'.                              "'&&'
      moff = varpos + mtvaroff.
      ASSIGN mtext2+moff(*) TO <mtxt>.
      REPLACE vark WITH '%%A%%' INTO <mtxt>.
      mtvaroff = 7.
    WHEN '<'.                                               "'&1'
      READ TABLE mttab INDEX vari.
      IF sy-subrc EQ 0.
        IF vark EQ '&<'.
          moff = varpos + mtvaroff.
          ASSIGN mtext2+moff(*) TO <mtxt>.
          ASSIGN mttab-text(mttab-len) TO <vtxt>.
          REPLACE '&' WITH <vtxt>     INTO <mtxt>.
          mtvaroff = mttab-len.
        ENDIF.
        IF vark EQ '$<'.
          moff = varpos + mtvaroff.
          ASSIGN mtext2+moff(*) TO <mtxt>.
          ASSIGN mttab-text(mttab-len) TO <vtxt>.
          REPLACE '$' WITH <vtxt>     INTO <mtxt>.
          mtvaroff = mttab-len.
        ENDIF.
      ELSE.
        IF vark EQ '&<'.
          moff = varpos + mtvaroff.
          ASSIGN mtext2+moff(*) TO <mtxt>.
          REPLACE '&' WITH ' ' INTO <mtxt>.
          mtvaroff = 1.
        ENDIF.
        IF vark EQ '$<'.
          moff = varpos + mtvaroff.
          ASSIGN mtext2+moff(*) TO <mtxt>.
          REPLACE '$' WITH ' ' INTO <mtxt>.
          mtvaroff = 1.
        ENDIF.
      ENDIF.
    WHEN '1'.                                               "'&1'
      READ TABLE mttab INDEX 1.
      IF sy-subrc EQ 0.
        moff = varpos + mtvaroff.
        ASSIGN mtext2+moff(*) TO <mtxt>.
        ASSIGN mttab-text(mttab-len) TO <vtxt>.
        REPLACE vark WITH <vtxt>     INTO <mtxt>.
        mtvaroff = mttab-len.
      ELSE.
        IF vari GT mparcnt.
          moff = varpos + mtvaroff.
          ASSIGN mtext2+moff(*) TO <mtxt>.
          REPLACE vark WITH '  ' INTO <mtxt>.
          mtvaroff = 2.
        ELSE.
          moff = varpos + mtvaroff.
          ASSIGN mtext2+moff(*) TO <mtxt>.
          REPLACE vark WITH '%%Z%%' INTO <mtxt>.
          mtvaroff = 7.
        ENDIF.
      ENDIF.
    WHEN '2'.                                               "'&2'
      READ TABLE mttab INDEX 2.
      IF sy-subrc EQ 0.
        moff = varpos + mtvaroff.
        ASSIGN mtext2+moff(*) TO <mtxt>.
        ASSIGN mttab-text(mttab-len) TO <vtxt>.
        REPLACE vark WITH <vtxt>     INTO <mtxt>.
        mtvaroff = mttab-len.
      ELSE.
        IF vari GT mparcnt.
          moff = varpos + mtvaroff.
          ASSIGN mtext2+moff(*) TO <mtxt>.
          REPLACE vark WITH '  ' INTO <mtxt>.
          mtvaroff = 2.
        ELSE.
          moff = varpos + mtvaroff.
          ASSIGN mtext2+moff(*) TO <mtxt>.
          REPLACE vark WITH '%%Z%%' INTO <mtxt>.
          mtvaroff = 7.
        ENDIF.
      ENDIF.
    WHEN '3'.                                               "'&3'
      READ TABLE mttab INDEX 3.
      IF sy-subrc EQ 0.
        moff = varpos + mtvaroff.
        ASSIGN mtext2+moff(*) TO <mtxt>.
        ASSIGN mttab-text(mttab-len) TO <vtxt>.
        REPLACE vark WITH <vtxt>     INTO <mtxt>.
        mtvaroff = mttab-len.
      ELSE.
        IF vari GT mparcnt.
          moff = varpos + mtvaroff.
          ASSIGN mtext2+moff(*) TO <mtxt>.
          REPLACE vark WITH '  ' INTO <mtxt>.
          mtvaroff = 2.
        ELSE.
          moff = varpos + mtvaroff.
          ASSIGN mtext2+moff(*) TO <mtxt>.
          REPLACE vark WITH '%%Z%%' INTO <mtxt>.
          mtvaroff = 7.
        ENDIF.
      ENDIF.
    WHEN '4'.                                               "'&4'
      READ TABLE mttab INDEX 4.
      IF sy-subrc EQ 0.
        moff = varpos + mtvaroff.
        ASSIGN mtext2+moff(*) TO <mtxt>.
        ASSIGN mttab-text(mttab-len) TO <vtxt>.
        REPLACE vark WITH <vtxt>     INTO <mtxt>.
        mtvaroff = mttab-len.
      ELSE.
        IF vari GT mparcnt.
          moff = varpos + mtvaroff.
          ASSIGN mtext2+moff(*) TO <mtxt>.
          REPLACE vark WITH '  ' INTO <mtxt>.
          mtvaroff = 2.
        ELSE.
          moff = varpos + mtvaroff.
          ASSIGN mtext2+moff(*) TO <mtxt>.
          REPLACE vark WITH '%%Z%%' INTO <mtxt>.
          mtvaroff = 7.
        ENDIF.
      ENDIF.

  ENDCASE.

  do_condense = space.

ENDFORM.