Tip

Structured ABAP programming by a COBOL programmer

This is an example of an ABAP program structured like a COBOL program. The program lists the record description of a Table/structure.
*******
* Start of REPORT ZMJB_001_print_table_structure                       *
*----------------------------------------------------------------------*
* PROPERTY INFORMATION:   MARIO J. BRYSON                              *
*                          (mario_bryson@farmersinsurance.com)         *
* PROGRAM NAME:           ZMJB_001_PRINT_TABLE_STRUCTURE               *
* BRIEF NARRATIVE:        The object of this program is to print a     *
*                         record description of a given table/structure*
* FUNCTIONALITY AREA:     ABAP UTILITY                                 *
* RELEASE:                4.6                                          *
* SAP REFERENCE PROGRAM:  N/A                                          *
*                                                                      *
*******************   MODIFICATION HISTORY   ***************************
* DATE:     DPSR #    AUTHOR    DESCRIPTION:                           *
*---------  ------    ------    ---------------------------------------*
* 04/10/99  mjb002    MJB       Completed and moved to production      *
*                               Transport DW2K902XXX                   *
*                               Transaction code = zmjb001             *
* 04/09/99  mjb001    MJB       Started                                *
* ---------------------------------------------------------------------*
*

    Requires Free Membership to View

INPUT/OUTPUT: * * ------------ * * INPUT: * * TABLES: 1. DD03P (STRUCTURE) * * OUTPUT: * * REPORT: 1. RECORD DESCRIPTION REPORT * ************************************************************************ Report zmjb_001_print_table_structure "Report name line-size 132 line-count 65(3) message-id z01. *----------------------------------------------------------------------* * TABLES * *----------------------------------------------------------------------* *Tables: dd03p. "structure *----------------------------------------------------------------------* * CONSTANTS * *----------------------------------------------------------------------* constants: *-------- c_a(1) type c value 'A'. "State for DDIF *----------------------------------------------------------------------* * VARIABLES * *----------------------------------------------------------------------* data: *--- v_dd03p_itab like dd03p occurs 0 with header line. "structure data: *--- v_start like dd03p-position, "Starting location v_end like dd03p-position, "Ending location v_record_count type p decimals 0. "line_count *----------------------------------------------------------------------* * SELECTION-SCREEN * *----------------------------------------------------------------------* selection-screen begin of block table_record with frame title text-001. parameters: "parameters *--------- p_tabnam like dcobjdef-name. "table name selection-screen end of block table_record. ************************************************************************ * START OF M A I N L O G I C * ************************************************************************ initialization. *------------- perform a_ini_010_initialization. "Initialization routine at selection-screen. *------------------ perform b_ass_010_at_selection_screen. "Screen start-of-selection. *----------------- perform c_sos_010_retrieve_dd03p. "Retrieve structure end-of-selection. *--------------- perform d_eos_010_report_dd03p. "Print structure top-of-page. *---------- perform z_top_010_top_of_page. "Top-of-page *----------------------------------------------------------------------* * END OF M A I N L O G I C * *----------------------------------------------------------------------* ************************************************************************ * Form a_ini_010_initialization * ************************************************************************ form a_ini_010_initialization. *---------------------------- v_start = 1. "Initialize to 1 endform. "a_ini_010_initialization. ************************************************************************ * Form b_ass_010_at_selection_screen * ************************************************************************ form b_ass_010_at_selection_screen. *--------------------------------- if p_tabnam is initial. "If blank enter a value for message e556 with text-002. "table name or structure endif. endform. "b_ass_010_at_selection_screen ************************************************************************ * Form c_sos_010_retrieve_dd03p * * This subroutine will retrieve the table structure and returned it in* * the internal table v_dd03p_itab. * ************************************************************************ form c_sos_010_retrieve_dd03p. *---------------------------- call function 'DDIF_TABL_GET' exporting name = p_tabnam state = c_a "Value is A langu = sy-langu tables dd03p_tab = v_dd03p_itab exceptions illegal_input = 1 others = 2. if sy-subrc <> 0. write: text-003. "table name or structure not found endif. endform. "c_sos_010_retrieve_dd03p ************************************************************************ * Form d_eos_010_report_dd03p * ************************************************************************ form d_eos_010_report_dd03p. *-------------------------- describe table v_dd03p_itab lines v_record_count. "Record count if v_record_count = 0. "no input v_dd03p_itab-ddtext = text-003. "table name or write v_dd03p_itab-ddtext under text-h01. "structure not found exit. "None to print endif. loop at v_dd03p_itab. "start of printing v_end = v_start + v_dd03p_itab-leng - 1. "add start,length "and subtract 1 write: / v_dd03p_itab-fieldname under text-h01, "field name v_dd03p_itab-position under text-h02, "seq v_dd03p_itab-keyflag under text-h03, "key v_dd03p_itab-inttype under text-h04, "type v_dd03p_itab-datatype under text-h05, "data v_dd03p_itab-leng under text-h06, "length v_dd03p_itab-decimals under text-h07, "dec v_start under text-h10, "start v_end under text-h11, "end v_dd03p_itab-ddtext under text-h08. "text v_start = v_end + 1. "add 1 to start loc endloop. "end of printing endform. "d_eos_010_report_dd03p. ************************************************************************ * Form z_top_010_top_of_page * ************************************************************************ form z_top_010_top_of_page. "top-of-page *------------------------- * 1st row of title *----------------- write: /001 'RECORD DESCRIPTION OF TABLE', 029 p_tabnam intensified color 6. write: /001 text-h01, "field name 012 text-h02, "seq 018 text-h03, "key 022 text-h04, "type 027 text-h05, "data 033 text-h06, "length 040 text-h07, "dec 047 text-h10, "start 053 text-h11, "end 059 text-h08. "text * 2nd row of title *----------------- write: / text-h09 under text-h05, "Type text-h12 under text-h10. "location uline. endform. "z_top_010_top_of_page. ************************************************************************ * end of REPORT ZMJB_001_print_table_structure * ************************************************************************ *no. text *--- --------------------------------- *001 table record description *002 table name or structure *003 table name or structure not found *h01 field name *h02 seq *h03 key *h04 type *h05 data *h06 length *h07 dec *h08 text *h09 type *h10 start *h11 end *h12 location *p_tabname = Table/Structure Name

This was first published in December 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.