REPORT Z_DISPLAY_IDOC_AND_DATA line-size 275.
************************************************************************
* This tool reads an existing Idoc and dispays the contents in a *
* spreadsheet format. The spreadsheet (MS-EXCEL) will be automatically *
* created if D_EXCEL = 'X'. *
************************************************************************
data: idoc_control like EDIDC,
NUMBER_OF_DATA_RECORDS like sy-dbcnt,
NUMBER_OF_STATUS_RECORDS like sy-dbcnt,
INT_EDIDS like edids occurs 0 with header line,
INT_EDIDD like edidd occurs 0 with header line.
TYPE-POOLS : LEDID.
data: STRUCT_TYPE TYPE LEDID_STRUCT_TYPE ,
IDOC_STRUCT TYPE LEDID_T_IDOC_STRUCT,
SEGMENTS TYPE LEDID_T_SEGMENT,
SEGMENT_STRUCT TYPE LEDID_T_SEGMENT_STRUCT,
excel_tab(2000) occurs 0 with header line.
parameter: DOCNUM like edidc-docnum obligatory, ""Idoc Number
sap_rel like SY-SAPRL default SY-SAPRL obligatory,
pi_ver like EDI_VERREC-VERSION default '3' obligatory,
d_excel as checkbox default 'X'. ""Download ?
start-of-selection.
perform read_idoc.
perform process_idoc.
if d_excel = 'X'.
perform download_to_excel.
endif.
end-of-selection.
FORM read_idoc.
CALL FUNCTION 'IDOC_READ_COMPLETELY'
EXPORTING
DOCUMENT_NUMBER = docnum
IMPORTING
IDOC_CONTROL = idoc_control
NUMBER_OF_DATA_RECORDS = NUMBER_OF_DATA_RECORDS
NUMBER_OF_STATUS_RECORDS = NUMBER_OF_STATUS_RECORDS
TABLES
INT_EDIDS = INT_EDIDS
INT_EDIDD = INT_EDIDD
EXCEPTIONS
DOCUMENT_NOT_EXIST = 1
DOCUMENT_NUMBER_INVALID = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "" read_idoc
FORM process_idoc.
perform read_idoc_structure.
perform display_data_records.
ENDFORM. "" process_idoc
FORM display_data_records.
data: PE_seg_HEADER like EDI_SAPI01,
segname like EDI_IAPI12-SEGMENTTYP,
prev_segname like EDI_IAPI12-SEGMENTTYP value ' ',
pt_fields2 like EDI_IAPI12 occurs 0 with header line,
PT_FVALUES2 like EDI_IAPI14 occurs 0 with header line,
byte_first type i,
byte_last type i,
field_val(50),
tmp_str(15),
tmp_str3(15),
seg_repeats type i value 0,
tmp_str2(15),
tab_cr(1) type x value '09',
tot_ctr type i value 0,
ctr type i value 0,
msg(40) type c.
data: IDOC_STRUCT_wa TYPE LEDID_IDOC_STRUCT.
sort int_edidd by segnum.
describe table int_edidd lines tot_ctr.
loop at int_edidd.
move int_edidd-segnam to segname.
clear msg.
concatenate 'Reading segment ' segname
into msg separated by space.
if tot_ctr <> 0.
ctr = ( 100 * sy-tabix ) / tot_ctr.
endif.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = ctr
TEXT = msg.
add 1 to seg_repeats.
clear tmp_str2.
if int_edidd-segnam <> prev_segname.
seg_repeats = 1.
clear: pe_seg_header, pt_fields2, pt_fvalues2.
refresh: pt_fields2, pt_fvalues2.
CALL FUNCTION 'SEGMENT_READ_COMPLETE'
EXPORTING
PI_SEGTYP = segname
PI_RELEASE = sap_rel
PI_VERSION = pi_ver
IMPORTING
PE_HEADER = pe_seg_header
TABLES
PT_FIELDS = pt_fields2
PT_FVALUES = pt_fvalues2
EXCEPTIONS
SEGMENT_UNKNOWN = 1
SEGMENT_STRUCTURE_UNKNOWN = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE 'I' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
prev_segname = int_edidd-segnam.
endif.
read table idoc_struct into idoc_struct_wa with key
segment_type = int_edidd-segnam.
if sy-subrc = 0.
IF IDOC_STRUCT_WA-SYNTAX_ATTRIB-MUSTFL = 'X'.
TMP_STR = 'Mandatory'. ""Mandatory
ELSE.
TMP_STR = 'Optional'. ""Optional
ENDIF.
if IDOC_STRUCT_wa-SEGMENT_TYPE_ATTRIB-QUALIFIER = 'X'.
tmp_str3 = 'Qualified'.
else.
tmp_str3 = 'Non-Qualified'.
endif.
shift IDOC_STRUCT_wa-SYNTAX_ATTRIB-OCCMAX
left deleting leading '0'.
move seg_repeats to tmp_str2.
condense: IDOC_STRUCT_wa-SYNTAX_ATTRIB-OCCMAX, tmp_str2.
concatenate tmp_str2 'of' IDOC_STRUCT_wa-SYNTAX_ATTRIB-OCCMAX
into tmp_str2 separated by space.
write :/ IDOC_STRUCT_wa-SEGMENT_TYPE,
tmp_str,
TMP_STR3,
tmp_str2,
IDOC_STRUCT_wa-SYNTAX_ATTRIB-HLEVEL,
IDOC_STRUCT_wa-SEGMENT_TYPE_ATTRIB-plast,
IDOC_STRUCT_wa-SEGMENT_TYPE_ATTRIB-DESCRP.
if d_excel = 'X'.
concatenate 'Segment Name' tab_cr
'Mand / Opt ' tab_cr
'Qual / non-Qual' tab_cr
'Seq of Max' tab_cr
'Level' tab_cr
'Owner' tab_cr
'Description'
into excel_tab.
append excel_tab.
concatenate IDOC_STRUCT_wa-SEGMENT_TYPE tab_cr
tmp_str tab_cr
TMP_STR3 tab_cr
tmp_str2 tab_cr
IDOC_STRUCT_wa-SYNTAX_ATTRIB-HLEVEL tab_cr
IDOC_STRUCT_wa-SEGMENT_TYPE_ATTRIB-plast tab_cr
IDOC_STRUCT_wa-SEGMENT_TYPE_ATTRIB-DESCRP
into excel_tab.
append excel_tab.
concatenate tab_cr
'Field Nma' tab_cr
'Type' tab_cr
'Length' tab_cr
'Byte From' tab_cr
'Byte To' tab_cr
'Description' tab_cr
'Value' tab_cr
'Qualifier Meaning'
into excel_tab.
append excel_tab.
endif.
endif.
sort pt_fields2 by field_pos.
byte_first = 0.
loop at pt_fields2.
clear: field_val.
byte_last = pt_fields2-EXTLEN.
write int_edidd-sdata+byte_first(byte_last) to
field_val left-justified.
shift pt_fields2-EXTLEN left deleting leading '0'.
shift pt_fields2-byte_first left deleting leading '0'.
shift pt_fields2-byte_last left deleting leading '0'.
write:/ ' ', pt_fields2-fieldname,
pt_fields2-datatype,
pt_fields2-EXTLEN,
pt_fields2-byte_first ,
pt_fields2-byte_last,
pt_fields2-descrp,
field_val.
read table pt_fvalues2 with key fieldname = pt_fields2-fieldname
fldvalue_l = field_val.
add byte_last to byte_first.
if sy-subrc = 0.
write : pt_fvalues2-descrp.
else.
clear pt_fvalues2-descrp.
endif.
if d_excel = 'X'.
concatenate tab_cr pt_fields2-fieldname tab_cr
pt_fields2-datatype tab_cr
pt_fields2-EXTLEN tab_cr
pt_fields2-byte_first tab_cr
pt_fields2-byte_last tab_cr
pt_fields2-descrp tab_cr
field_val tab_cr
pt_fvalues2-descrp
into excel_tab.
append excel_tab.
endif.
endloop.
endloop.
ENDFORM. "" display_data_records
FORM read_idoc_structure.
data: idoctype type LEDID_IDOCTYPE.
if not idoc_control-cimtyp is initial.
STRUCT_TYPE = 'E'. ""Extended
idoctype = idoc_control-cimtyp.
else.
STRUCT_TYPE = 'B'. ""Basic
idoctype = idoc_control-idoctp.
endif.
CALL FUNCTION 'IDOC_TYPE_COMPLETE_READ'
EXPORTING
RELEASE = sap_rel
STRUCT_TYPE = STRUCT_TYPE
IDOCTYPE = idoctype
VERSION = pi_ver
* IMPORTING
* IDOC_TYPE = idoctype
TABLES
IDOC_STRUCT = idoc_struct
SEGMENTS = segments
SEGMENT_STRUCT = segment_struct
EXCEPTIONS
IDOCTYPE_UNKNOWN = 1
IDOCSTRUCT_UNKNOWN = 2
SEGMENT_DATA_MISSING = 3
ILLEGAL_STRUCT_TYPE = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "" read_idoc_structure
FORM download_to_excel.
data: name like RLGRAP-FILENAME.
shift docnum left deleting leading '0'.
concatenate docnum '-' idoc_control-idoctp '.xls'
into name.
CALL FUNCTION 'RH_START_EXCEL_WITH_DATA'
EXPORTING
DATA_NAME = name
DATA_TYPE = 'ASC'
WAIT = ' '
TABLES
DATA_TAB = excel_tab
EXCEPTIONS
NO_BATCH = 1
EXCEL_NOT_INSTALLED = 2
WRONG_VERSION = 3
INTERNAL_ERROR = 4
INVALID_TYPE = 5
CANCELLED = 6
DOWNLOAD_ERROR = 7
OTHERS = 8
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "" download_to_excel
Friday, November 23, 2007
sap abap program for Reads an existing Idoc and dispays the contents in a spreadsheet format
Labels:
idocs.
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2007
(952)
-
▼
November
(716)
- SAP Paper Documents
- SAP Repository
- SAP R/3 Implementation and Maintenance Tips
- ABAP/4 programming language overview
- The interactive eLearning system for ABAP™
- Helpful System Administration ABAPS
- free download abap programmin pdf book
- examples of real time objects in sap abap(1)
- examples of real time objects in sap abap
- work flow example2
- Workflow tips
- Miscellaneous sap abap faq
- BDC , LSMW, Conversions faq in abap
- Sap Scripts & Smart forms faqs in abap
- performance tuning in abap faqs
- Real Time BDC & LSMW faqs
- Real Time ABAP Internal Tables faqs
- Real Time ABAP Reports faqs
- Real Time questions ..in sap ABAP
- SAP ABAP FAQ (Technical)
- ABAP and Unicode
- ABAP and JavaScript
- ABAP Objects
- ABAP Database Access
- Running ABAP Programs
- ABAP User Dialogs
- The ABAP Programming Language
- Creating and Changing ABAP Programs
- Overview of the Components of Application Programs
- Introduction to ABAP
- ABAP Programming Documentation
- FREE DOWNLOAD ALE, EDI & IDOCS
- Conversion of IDOCs to XML.pdf
- FREE DOWNLOAD IDOC Interface Technology
- FREE DOWNLOAD EDI, IDOC Interface
- FREE DOWNLOAD IDOC BOOK
- FREE DOWNLOAD LSMW - Idoc Inbound Processing
- FREE DOWNLOAD SAP ABAP Idoc Interface
- FREE DOWNLOAD Java for SAP
- FREE DOWNLOAD Java for ABAP Programmers
- FREE DOWNLOAD Java and BAPI technology for EP
- free download Building Web Services with Java and ...
- free download Enable SAP with the power of Javascript
- FREE DOWNLOAD ABAP Training Simulator
- FREE DOWNLOAD SAP Accounting Training Simulators
- free download SAPScripts Made Easy
- CONDENSE
- CONSTANTS
- ABAP Quick Viewer
- sap abap XXL (EXtended Export of Lists)
- Some ABAP/4 Query header line variable
- Understanding SAP Query
- ABAP/4 Query
- ABAP/4 Query Hints and Tips
- SAP Website Links Exchange for ABAP, Basis or Cons...
- sap abap Program for Generate IDoc
- sap abap program for Reads an existing Idoc and di...
- List of ABAP Function modules
- sap abap FTP programming
- sap abap program for Issuing an Unix Command from ...
- sap abap program for RFC call to get Server List
- sap abap program for A SAP Pop-out Calculator
- sap ABAP program for Timers and Auto-refresh
- sap abap program for WS_EXECUTE to called External...
- sap abap programming Execute DOS Command from ABAP...
- To execute a dos command from ABAP
- sap abap program for Make your SAPGUI Disappear an...
- sap abap program for Using Function Modules F4_FIL...
- abp program for How to Restrict the Select Options
- sap abap program for Take Values from Selection-Sc...
- sap abap program for Change Text Into Password
- sap abap program for Function Module for Encryptio...
- sap abap program for FM VRM_SET_VALUE To List Box
- sap abap program for Value Request For Parameter
- sap abap program for Pop a Message to specific SAP...
- ABAP Pop-out box for user confirmation
- sap ABAP program for POP-UP Window
- sap abap program Sample XML Source Code For SAP
- sap abap XML file to word document through SAP
- sap abap program for How to Write Web Reports in SAP
- sap abap conversion Program to Test Line Selection...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for Convert SAP Spool List to HTML
- sap program for Convert Month to Word in ABAP
- ABAP function to convert Number to Words
- sap abap program for How to Create Tree Control
- sap abap A sample Tree Programming
-
▼
November
(716)
No comments:
Post a Comment