|
|
This website is not affiliated with, sponsored by, or approved by SAP AG.
Development (ABAP Development WorkBench, ABAP/4 programming)
Moderators: thx4allthefish, Snowy, Gothmog, YuriT
by abapnoob » Mon Mar 26, 2012 10:57 pm
Good day, Need help. I need a program that will run like se80. where i need to get all elements when you enter the program name. and also the pbo and pai modules. who knows how to do this? i really need your help . thank you!!
-
abapnoob
-
- Posts: 9
- Joined: Wed Mar 21, 2012 11:19 pm
by VLozano » Tue Mar 27, 2012 2:53 am
err... do you really think the use of all those "!" and a captionous "HELP" will urge us? (Removed this one. Yuri)
I think a subject like "How to retrieve all elements from a program" would be useful for us to get an idea about what do you think you need, and future searches a hint to know if the thread is useful or a complete waste of time. Edit your subject and MAYBE you will get more help. Take a look at this code and expand it as further as you will need. It's not bug-free guaranteed, I don't will provide any support and I will deny any responsability if you crash something using it. - Code: Select all
REPORT zcavxltr01_scan_tcode LINE-SIZE 132 MESSAGE-ID zppes00.
* Global declarations--------------------------------------------------- CONSTANTS: c_tran TYPE trobjtype VALUE 'TRAN', c_prog TYPE trobjtype VALUE 'PROG', c_incl TYPE trobjtype VALUE 'INCL', c_func TYPE trobjtype VALUE 'FUNC', c_fugr TYPE trobjtype VALUE 'FUGR'.
DATA: subrc TYPE sy-subrc. DATA: pgmna TYPE program_id. DATA: BEGIN OF w_data, tcode TYPE tcode, objtype TYPE trobjtype, "object type objname TYPE sobj_name, "object name scanned TYPE xfeld, "object has been scanned END OF w_data, t_data LIKE TABLE OF w_data.
* Selection-screen------------------------------------------------------ SELECT-OPTIONS: r_tcode FOR w_data-tcode.
* Events---------------------------------------------------------------- INITIALIZATION.
START-OF-SELECTION. PERFORM check_tcode. IF subrc = 0. PERFORM scan_tcode. ENDIF.
END-OF-SELECTION. CHECK subrc = 0. SORT t_data BY objtype ASCENDING objname ASCENDING. DELETE ADJACENT DUPLICATES FROM t_data COMPARING objtype objname. DELETE t_data WHERE objname = ''. DESCRIBE TABLE t_data. IF sy-tfill <> 0. PERFORM output. ELSE. MESSAGE i158 WITH 'Nothing found.'. ENDIF.
* Forms----------------------------------------------------------------- *---------------------------------------------------------------------* * FORM check_tcode * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* FORM check_tcode. DATA: l_tcode TYPE tcode.
SELECT tcode INTO l_tcode FROM tstc WHERE tcode IN r_tcode. w_data-tcode = l_tcode. w_data-objtype = c_tran. w_data-objname = l_tcode. APPEND w_data TO t_data. ENDSELECT. subrc = sy-subrc. IF sy-subrc <> 0. MESSAGE i158 WITH 'Wrong transaction codes.'. ENDIF. ENDFORM.
*---------------------------------------------------------------------* * FORM scan_tcode * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* FORM scan_tcode. DO. READ TABLE t_data INTO w_data WITH KEY scanned = space. IF sy-subrc = 0. w_data-scanned = 'X'. MODIFY t_data FROM w_data INDEX sy-tabix. PERFORM scan_object USING w_data. ELSE. EXIT. ENDIF. ENDDO. ENDFORM.
*---------------------------------------------------------------------* * FORM output * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* FORM output. SORT t_data BY objtype ASCENDING objname ASCENDING. LOOP AT t_data INTO w_data. WRITE: / w_data-tcode, w_data-objtype, w_data-objname. ENDLOOP. ENDFORM.
*---------------------------------------------------------------------* * FORM scan_object * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* * --> LW_DATA * *---------------------------------------------------------------------* FORM scan_object USING lw_data LIKE w_data. CASE w_data-objtype. WHEN c_fugr. WHEN c_func. IF lw_data-objname(1) = 'Z'. PERFORM scan_func USING lw_data. ENDIF. WHEN c_incl OR c_prog. IF lw_data-objname(1) = 'Z' OR lw_data-objname(5) = 'SAPMZ' OR lw_data-objname(2) = 'MZ'. PERFORM scan_prog USING lw_data. ENDIF. WHEN c_tran. PERFORM scan_tran USING lw_data. ENDCASE. ENDFORM.
*---------------------------------------------------------------------* * FORM scan_prog * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* * --> LW_DATA * *---------------------------------------------------------------------* FORM scan_prog USING lw_data LIKE w_data. DATA: l_pname TYPE rpy_prog-progname, lt_source TYPE TABLE OF abapsource, lw_source TYPE abapsource, lt_incl TYPE TABLE OF rpy_repo, lw_incl TYPE rpy_repo, lw_data2 LIKE w_data.
l_pname = w_data-objname. CALL FUNCTION 'RPY_PROGRAM_READ' EXPORTING program_name = l_pname only_source = 'X' * IMPORTING * PROG_INF = TABLES include_tab = lt_incl source = lt_source EXCEPTIONS cancelled = 1 not_found = 2 permission_error = 3 OTHERS = 4. IF sy-subrc <> 0. EXIT. ENDIF.
* Code LOOP AT lt_source INTO lw_source. CLEAR lw_data2. CONDENSE lw_source-line. CHECK lw_source-line <> ''. CHECK lw_source-line(1) <> '*'. IF lw_source-line(16) = 'CALL TRANSACTION'. lw_data2-objtype = c_tran. lw_data2-objname = lw_source-line+17. SEARCH lw_data2-objname FOR ''''. IF sy-subrc = 0 AND sy-fdpos = 0. lw_data2-objname = lw_data2-objname+1. IF sy-subrc = 0. SEARCH lw_data2-objname FOR ''''. IF sy-subrc = 0. lw_data2-objname = lw_data2-objname(sy-fdpos). ELSE. SEARCH lw_data2-objname FOR 'USING'. IF sy-subrc = 0. lw_data2-objname = lw_data2-objname(sy-fdpos). ENDIF. ENDIF. ENDIF. ELSE. SEARCH lw_data2-objname FOR 'USING'. IF sy-subrc = 0. lw_data2-objname = lw_data2-objname(sy-fdpos). ENDIF. ENDIF. CONDENSE lw_data2-objname. ELSE. IF lw_source-line(13) = 'CALL FUNCTION'. lw_data2-objtype = c_func. lw_data2-objname = lw_source-line+15. CONDENSE lw_data2-objname. ELSE. IF lw_source-line(6) = 'SUBMIT'. lw_data2-objtype = c_prog. lw_data2-objname = lw_source-line+8. CONDENSE lw_data2-objname. ENDIF. ENDIF. ENDIF. REPLACE '''' WITH space INTO lw_data2-objname. CONDENSE lw_data2-objname. READ TABLE t_data INTO lw_data2 WITH KEY tcode = lw_data-tcode objtype = lw_data2-objtype objname = lw_data2-objname. IF sy-subrc <> 0. CHECK lw_data2-objname <> ''. lw_data2-tcode = lw_data-tcode. APPEND lw_data2 TO t_data. ENDIF. ENDLOOP.
* Includes LOOP AT lt_incl INTO lw_incl. CLEAR lw_data2. lw_data2-objtype = c_incl. lw_data2-objname = lw_incl-inclname. READ TABLE t_data INTO lw_data2 WITH KEY tcode = lw_data-tcode objtype = c_incl objname = lw_data2-objname. IF sy-subrc <> 0. lw_data2-tcode = lw_data-tcode. APPEND lw_data2 TO t_data. ENDIF. ENDLOOP. ENDFORM.
*---------------------------------------------------------------------* * FORM scan_func * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* * --> LW_DATA * *---------------------------------------------------------------------* FORM scan_func USING lw_data LIKE w_data. DATA: lw_tfdir TYPE tfdir. DATA: l_pname TYPE rpy_prog-progname, lt_source TYPE TABLE OF abapsource, lw_source TYPE abapsource, lt_incl TYPE TABLE OF rpy_repo, lw_incl TYPE rpy_repo, lw_data2 LIKE w_data.
SELECT SINGLE * INTO lw_tfdir FROM tfdir WHERE funcname = lw_data-objname. CHECK sy-subrc = 0.
CONCATENATE lw_tfdir-pname+3 'U' lw_tfdir-include INTO l_pname.
CALL FUNCTION 'RPY_PROGRAM_READ' EXPORTING program_name = l_pname only_source = 'X' * IMPORTING * PROG_INF = TABLES include_tab = lt_incl source = lt_source EXCEPTIONS cancelled = 1 not_found = 2 permission_error = 3 OTHERS = 4. IF sy-subrc <> 0. EXIT. ENDIF.
* Code LOOP AT lt_source INTO lw_source. CLEAR lw_data2. CONDENSE lw_source-line. CHECK lw_source-line <> ''. CHECK lw_source-line(1) <> '*'. IF lw_source-line(16) = 'CALL TRANSACTION'. lw_data2-objtype = c_tran. lw_data2-objname = lw_source-line+17. SEARCH lw_data2-objname FOR ''''. IF sy-subrc = 0 AND sy-fdpos = 0. lw_data2-objname = lw_data2-objname+1. IF sy-subrc = 0. SEARCH lw_data2-objname FOR ''''. IF sy-subrc = 0. lw_data2-objname = lw_data2-objname(sy-fdpos). ELSE. SEARCH lw_data2-objname FOR 'USING'. IF sy-subrc = 0. lw_data2-objname = lw_data2-objname(sy-fdpos). ENDIF. ENDIF. ENDIF. ELSE. SEARCH lw_data2-objname FOR 'USING'. IF sy-subrc = 0. lw_data2-objname = lw_data2-objname(sy-fdpos). ENDIF. ENDIF. CONDENSE lw_data2-objname. ELSE. IF lw_source-line(13) = 'CALL FUNCTION'. lw_data2-objtype = c_func. lw_data2-objname = lw_source-line+15. CONDENSE lw_data2-objname. ELSE. IF lw_source-line(6) = 'SUBMIT'. lw_data2-objtype = c_prog. lw_data2-objname = lw_source-line+8. CONDENSE lw_data2-objname. ENDIF. ENDIF. ENDIF. REPLACE '''' WITH space INTO lw_data2-objname. CONDENSE lw_data2-objname. READ TABLE t_data INTO lw_data2 WITH KEY tcode = lw_data-tcode objtype = lw_data2-objtype objname = lw_data2-objname. IF sy-subrc <> 0. CHECK lw_data2-objname <> ''. lw_data2-tcode = lw_data-tcode. APPEND lw_data2 TO t_data. ENDIF. ENDLOOP.
* Includes LOOP AT lt_incl INTO lw_incl. CLEAR lw_data2. lw_data2-objtype = c_incl. lw_data2-objname = lw_incl-inclname. READ TABLE t_data INTO lw_data2 WITH KEY tcode = lw_data-tcode objtype = c_incl objname = lw_data2-objname. IF sy-subrc <> 0. lw_data2-tcode = lw_data-tcode. APPEND lw_data2 TO t_data. ENDIF. ENDLOOP. ENDFORM.
*---------------------------------------------------------------------* * FORM scan_tran * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* * --> LW_DATA * *---------------------------------------------------------------------* FORM scan_tran USING lw_data LIKE w_data. DATA: lw_data2 LIKE w_data.
SELECT SINGLE tcode pgmna INTO (lw_data2-tcode, lw_data2-objname) FROM tstc WHERE tcode = lw_data-tcode. IF sy-subrc = 0. lw_data2-objtype = c_prog. APPEND lw_data2 TO t_data. ENDIF. ENDFORM.
Tuly Idiots Because we know we are part of the problem
-
VLozano
-
- Posts: 4987
- Joined: Mon Sep 13, 2004 8:17 am
- Location: Idioci-ty
-
by Rich » Tue Mar 27, 2012 7:24 am
See viewtopic.php?f=13&t=359970&start=0Ok, you are starting to get on my nerves. SAP provides all of the functionality that you seem to require. Why are you so opposed to using standard functionality. Why re-invenmt the wheel ? What is it you are actually aiming to do and why ?
-
Rich
-
- Posts: 6919
- Joined: Thu Oct 31, 2002 4:47 pm
- Location: Geneva
-
by YuriT » Wed Mar 28, 2012 4:00 am
Create a custom transaction code and assign it to SAPMSEU0 program. This will be as close to SE80 as you'll ever get.
-
YuriT
-
- Posts: 888
- Joined: Fri Feb 03, 2006 6:40 am
- Location: Basel/Riga
by abapnoob » Wed Mar 28, 2012 9:41 pm
Sorry for that sir VLozano, what I need is, when I enter the program name, all PBO modules and PAI modules will appear and all the elements used.
-
abapnoob
-
- Posts: 9
- Joined: Wed Mar 21, 2012 11:19 pm
by abapnoob » Wed Mar 28, 2012 9:59 pm
Rich wrote:See viewtopic.php?f=13&t=359970&start=0Ok, you are starting to get on my nerves. SAP provides all of the functionality that you seem to require. Why are you so opposed to using standard functionality. Why re-invenmt the wheel ? What is it you are actually aiming to do and why ?
Because I need to create a program for a report, that when you enter a program name, it will retrieved all PBO and PAI modules and all elements used in the program and it will be display as word document or spreadsheet.
-
abapnoob
-
- Posts: 9
- Joined: Wed Mar 21, 2012 11:19 pm
by VLozano » Fri Mar 30, 2012 4:40 am
Rich's main question is: why do you need to create that kind of program? Or (I suppose) which kind of user should need that?
It's not a business requirement, it doesn't add nothing to the productivity, and it will add nothing to the quality of your work. If you need to automate some kind of weird documentation system, I wonder which kind of depravate should need the documentation at that level of detail.
The only thing I can think in to help you is to take a look at my code snipet and try to modify it using search text functions, looking for lines that start with MODULE or FORM.
Anyway, it's a very useless way to waste your time.
Tuly Idiots Because we know we are part of the problem
-
VLozano
-
- Posts: 4987
- Joined: Mon Sep 13, 2004 8:17 am
- Location: Idioci-ty
-
by Sharpshooter » Fri Mar 30, 2012 6:30 am
VLozano wrote:Rich's main question is: why do you need to create that kind of program? Or (I suppose) which kind of user should need that?
Sounds like one who wishes to pinch the work of others and take it with him (or her)!
Good luck!
-
Sharpshooter
-
- Posts: 934
- Joined: Wed Mar 17, 2010 12:01 pm
- Location: In the dark
by YuriT » Sun Apr 01, 2012 9:31 pm
Or a bootcamp exercise. If so then pretty tough one. I have looked at it for some 15 minutes and still have a very vague idea how to do that 
-
YuriT
-
- Posts: 888
- Joined: Fri Feb 03, 2006 6:40 am
- Location: Basel/Riga
by Rich » Mon Apr 02, 2012 6:32 am
YuriT wrote:Or a bootcamp exercise. If so then pretty tough one. I have looked at it for some 15 minutes and still have a very vague idea how to do that 
I've got a program of mine that'll download the kitchen sink. Only because a project that I was on was canned after 5 years because the company I was with was bought out by an asset stripper who wanted to un-integrate all the production plants, warehouses etc etc that we had worked hard to integrate. They wanted all the software destroyed (for tax reasons) as well so before that happened I was given the task of writing this thing so that all the developers could take a copy. It's not easy....
-
Rich
-
- Posts: 6919
- Joined: Thu Oct 31, 2002 4:47 pm
- Location: Geneva
-
Return to ABAP
Who is online
Users browsing this forum: Google [Bot] and 8 guests
|
|