Posted: Sat Jan 26, 2008 4:54 pm Post subject: Generate and display a documentation for a SHDB record
This report generates and displays a documentation for a SHDB record
Code:
REPORT z_alv_shdb_doc.
*---------------------------------------------------------------------*
* This report generates and displays a documentation for a SHDB record*
*---------------------------------------------------------------------*
* Author : Michel PIOUD *
* Email : [email protected] HomePage : http://www.geocities.com/mpioud *
*---------------------------------------------------------------------*
* Macro definition
DEFINE m_append.
add 1 to g_j.
gt_data-colx = g_i.
gt_data-colj = g_j.
append gt_data.
clear gt_data.
END-OF-DEFINITION.
CONSTANTS c_%bdc(4) VALUE '%BDC'.
TABLES apqi. " Queue info definition
SELECTION-SCREEN :
SKIP, BEGIN OF LINE, COMMENT 10(20) v_1 FOR FIELD p_grpid."#EC NEEDED
* SHDB Group name
PARAMETERS p_grpid LIKE apqi-groupid OBLIGATORY.
SELECTION-SCREEN END OF LINE.
DATA:
* SHDB Queue identification (unique key)
p_qid LIKE apqi-qid,
BEGIN OF gs_field,
ddtext LIKE dd04v-ddtext,
type LIKE dd03l-datatype,
length LIKE dd03l-leng,
decimal LIKE dd03l-decimals,
tab_control LIKE dd03l-checktable,
END OF gs_field,
* Data to display
BEGIN OF gt_data OCCURS 0,
colx TYPE i,
colj TYPE i,
col0(40),
col1(100),
col2(100),
col3(3),
col4(3),
col5(4),
col6(40),
color(4),
box,
END OF gt_data,
g_descript(100), " Work field (column 3)
g_prog TYPE progname,
g_i TYPE i,
g_j TYPE i,
* Internal table of data from SHDB record
gt_dynprotab LIKE bdcdata OCCURS 0 WITH HEADER LINE.
*---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_grpid.
PERFORM f_choose_shdb USING 'GROUPID'
'P_GRPID'
CHANGING p_grpid.
CHECK NOT p_grpid IS INITIAL.
SELECT qid INTO p_qid FROM apqi UP TO 2 ROWS
WHERE groupid = p_grpid
AND mandant = sy-mandt
AND datatyp = c_%bdc.
ENDSELECT.
CHECK sy-dbcnt = 2.
PERFORM f_choose_shdb USING 'QID' ''
CHANGING p_qid.
*---------------------------------------------------------------------*
AT SELECTION-SCREEN.
IF NOT p_qid IS INITIAL.
* SHDB record exists ?
SELECT qid INTO p_qid FROM apqi UP TO 1 ROWS
WHERE qid = p_qid
AND groupid = p_grpid
AND mandant = sy-mandt
AND datatyp = c_%bdc.
ENDSELECT.
CHECK sy-subrc NE 0.
ENDIF.
* SHDB record exists ?
SELECT qid INTO p_qid FROM apqi UP TO 1 ROWS
WHERE groupid = p_grpid
AND mandant = sy-mandt
AND datatyp = c_%bdc.
ENDSELECT.
CHECK sy-subrc NE 0.
* Recording & is not available
MESSAGE i627(ms) WITH p_grpid.
STOP.
IF sy-subrc >< 0.
* Recording & is not available
MESSAGE s627(ms) WITH p_qid.
EXIT.
ENDIF.
CLEAR apqi.
SELECT * FROM apqi UP TO 1 ROWS WHERE qid = p_qid
AND datatyp = c_%bdc
AND mandant = sy-mandt.
ENDSELECT.
CHECK sy-subrc EQ 0.
* SHDB properties
CLEAR g_descript.
WRITE apqi-credate TO g_descript DD/MM/YY.
CONCATENATE 'Created on :' g_descript '-'
INTO g_descript SEPARATED BY space.
WRITE apqi-cretime TO g_descript+22.
CONCATENATE g_descript 'by' apqi-creator
INTO g_descript SEPARATED BY space.
LOOP AT gt_dynprotab.
CLEAR g_descript.
CASE gt_dynprotab-dynbegin.
WHEN 'T'. " New transaction
PERFORM transaction.
WHEN 'X'. " New dynpro
PERFORM dynpro.
WHEN space. " Dynpro field
IF gt_dynprotab-fnam(10) = 'BDC_OKCODE'.
PERFORM okcode.
ELSEIF gt_dynprotab-fnam(10) = 'BDC_CURSOR'.
PERFORM cursor.
ELSEIF gt_dynprotab-fnam(10) = 'BDC_SUBSCR'.
PERFORM subscr.
ELSE.
PERFORM f_field.
ENDIF.
ENDCASE.
ENDLOOP.
PERFORM f_display.
*---------------------------------------------------------------------*
* Form COMPLETE *
*---------------------------------------------------------------------*
FORM complete USING u_field TYPE c.
DATA :
l_table LIKE dd03l-tabname, " Table name
l_field LIKE dd03l-fieldname, " Field Name
l_temp LIKE dd03l-fieldname, "#EC NEEDED
lt_dd03l LIKE dd03l OCCURS 0 WITH HEADER LINE,
lt_dd04v LIKE dd04v OCCURS 0 WITH HEADER LINE.
CLEAR gs_field.
SPLIT u_field AT '-' INTO l_table l_field.
IF l_table(1) = '*'.
SHIFT l_table.
ENDIF.
IF l_field CA '('.
SPLIT l_field AT '(' INTO l_field l_temp.
ENDIF.
* Get text for field
CALL FUNCTION 'FIELDNAME_ROLLNAME_TEXT'
EXPORTING
i_as4local = 'A'
i_fieldname = l_field
i_tabname = l_table
TABLES
e_dd03l = lt_dd03l
e_dd04v = lt_dd04v
EXCEPTIONS
error_in_parameters = 1
not_found = 2
OTHERS = 3.
CHECK sy-subrc EQ 0.
CLEAR : lt_dd03l, lt_dd04v, gs_field.
READ TABLE lt_dd03l INDEX 1.
READ TABLE lt_dd04v INDEX 1.
MOVE lt_dd03l-leng TO gs_field-length.
MOVE lt_dd03l-datatype TO gs_field-type.
MOVE lt_dd03l-checktable TO gs_field-tab_control.
MOVE lt_dd04v-ddtext TO gs_field-ddtext.
MOVE lt_dd03l-decimals TO gs_field-decimal.
ENDFORM. " COMPLETE
*---------------------------------------------------------------------*
* Form TRANSACTION
*---------------------------------------------------------------------*
FORM transaction.
* Read transaction text
SELECT SINGLE ttext INTO g_descript FROM tstct
WHERE tcode = gt_dynprotab-fnam
AND sprsl = sy-langu.
IF sy-subrc NE 0.
* Read transaction text
SELECT ttext INTO g_descript FROM tstct UP TO 1 ROWS
WHERE tcode = gt_dynprotab-fnam.
ENDSELECT.
IF sy-subrc NE 0.
g_descript = 'Text of transaction unkowned'. "#EC *
ENDIF.
ENDIF.
ENDFORM. " TRANSACTION
*---------------------------------------------------------------------*
* Form DYNPRO
*---------------------------------------------------------------------*
FORM dynpro.
* Read dynpro text
SELECT SINGLE dtxt INTO g_descript FROM d020t
WHERE prog = gt_dynprotab-program
AND dynr = gt_dynprotab-dynpro
AND lang = sy-langu.
IF sy-subrc NE 0.
* Read dynpro text
SELECT dtxt INTO g_descript FROM d020t UP TO 1 ROWS
WHERE prog = gt_dynprotab-program
AND dynr = gt_dynprotab-dynpro.
ENDSELECT.
IF sy-subrc NE 0.
g_descript = 'Unkowned'. "#EC *
ENDIF.
ENDIF.
ENDFORM. " DYNPRO
*---------------------------------------------------------------------*
* Form OKCODE
*---------------------------------------------------------------------*
FORM okcode.
* Read OKcode text
SELECT text INTO gt_data-col2 UP TO 1 ROWS
FROM rsmptexts
WHERE progname = g_prog
AND sprsl = sy-langu
AND obj_code = l_code.
ENDSELECT.
IF sy-subrc NE 0.
* Read OKcode text
SELECT text INTO gt_data-col2 UP TO 1 ROWS
FROM rsmptexts
WHERE progname = g_prog
AND obj_code = l_code.
ENDSELECT.
ENDIF.
ENDFORM. " OKCODE
*---------------------------------------------------------------------*
* Form cursor
*---------------------------------------------------------------------*
FORM cursor.
IF gt_dynprotab-fval CA '-'.
PERFORM complete USING gt_dynprotab-fval.
ENDIF.
ENDFORM. " CURSOR
*---------------------------------------------------------------------*
* Form subscr
*---------------------------------------------------------------------*
FORM subscr.
* Read Subscr text
SELECT SINGLE dtxt INTO g_descript FROM d020t
WHERE prog = l_prog
AND dynr = l_dynp
AND lang = sy-langu.
IF sy-subrc NE 0.
* Read Subscr text
SELECT dtxt INTO g_descript FROM d020t UP TO 1 ROWS
WHERE prog = l_prog
AND dynr = l_dynp.
ENDSELECT.
IF sy-subrc NE 0.
g_descript = 'Unkwoned'. "#EC *
ENDIF.
ENDIF.
CONDENSE gt_dynprotab-fval.
gt_data-col0 = gt_dynprotab-fnam.
gt_data-col1 = gt_dynprotab-fval.
gt_data-col2 = g_descript.
m_append.
ENDFORM. " SUBSCR
*---------------------------------------------------------------------*
* Form F_FIELD
*---------------------------------------------------------------------*
FORM f_field.
IF gt_dynprotab-fnam CA '-'.
PERFORM complete USING gt_dynprotab-fnam.
ENDIF.
ENDFORM. " F_FIELD
*---------------------------------------------------------------------*
* FORM F_DISPLAY *
*---------------------------------------------------------------------*
FORM f_display.
TYPE-POOLS: slis. " Generic list types
DATA :
ls_layout TYPE slis_layout_alv,
ls_print TYPE slis_print_alv,
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
ls_grid_settings TYPE lvc_s_glay,
lt_excluding TYPE slis_t_extab.
ls_fieldcat-just = 'R'.
MODIFY lt_fieldcat FROM ls_fieldcat
TRANSPORTING just WHERE fieldname = 'COL3' OR fieldname = 'COL4'.
ls_fieldcat-tech = 'X'.
MODIFY lt_fieldcat FROM ls_fieldcat
TRANSPORTING tech WHERE fieldname = 'COLX' OR fieldname = 'COLJ'
OR fieldname = 'COLOR' OR fieldname = 'BOX'.
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.
*---------------------------------------------------------------------*
* Form F_CHOOSE_SHDB
*---------------------------------------------------------------------*
FORM f_choose_shdb USING u_value1 TYPE fieldname
u_value2 TYPE dynfnam
CHANGING u_val.
TYPES:
BEGIN OF ty_s_values,
qid TYPE apq_quid,
groupid TYPE apq_grpn,
creator TYPE apq_mapn,
credate TYPE apq_crda,
cretime TYPE apq_crti,
transcnt TYPE apq_tran,
msgcnt TYPE apq_reco,
END OF ty_s_values.
DATA:
lt_values TYPE TABLE OF ty_s_values,
Lt_return TYPE HRRETURN_TAB WITH HEADER LINE,
l_progname TYPE sy-repid,
l_dynnum TYPE sy-dynnr.
l_progname = sy-repid.
l_dynnum = sy-dynnr.
IF u_value1 = 'GROUPID'.
SELECT *
FROM apqi
INTO CORRESPONDING FIELDS OF TABLE lt_values
WHERE datatyp = c_%bdc
AND mandant = sy-mandt.
ELSE.
SELECT *
FROM apqi
INTO CORRESPONDING FIELDS OF TABLE lt_values
WHERE datatyp = c_%bdc
AND mandant = sy-mandt
AND groupid = p_grpid.
ENDIF.
* F4 help
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = u_value1
dynpprog = l_progname
dynpnr = l_dynnum
dynprofield = u_value2
value_org = 'S'
TABLES
value_tab = lt_values
return_tab = lt_return
EXCEPTIONS
parameter_error = 1
no_values_found = 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.
CHECK NOT lt_return[] IS INITIAL.
READ TABLE lt_return INDEX 1.
u_val = lt_return-fieldval.
ENDFORM. " F_CHOOSE_SHDB
***************** END OF PROGRAM Z_ALV_SHDB_DOC ***********************
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.