2008 Jan 08 9:01 AM
Hi Folks,
I have a requirement to add two new fields to store the SAD which is a calucation of Amount in Local currency * 0.39 of the corresponding Movement Type.Can anyone here please let me know how to add these two new fields in the fieldcatalog of the heirarchical alv output.
Thanks,
K.Kiran.
Hi Folks,
I have a requirement to add two new fields to store the SAD which is a calucation of Amount in Local currency * 0.39 of the corresponding Movement Type.Can anyone here please let me know how to add these two new fields in the fieldcatalog of the heirarchical alv output.
Thanks,
K.Kiran.
2008 Feb 18 4:02 AM
Hi,
There is a perfom build_fieldcatalog but I was not able to understand the way it is coded.Can anyone here please let me know how a field catalog is decalred for this heirarchial alv of MB51.
Thanks,
K.Kiran.
2008 Feb 19 3:26 AM
REPORT ZMB51 .
DATA LIST_TAB TYPE TABLE OF ABAPLIST.
DATA: BEGIN OF olist OCCURS 0,
filler1(1500) TYPE c,
END OF olist.
DATA: BEGIN OF temp OCCURS 0,
filler1(1500) TYPE c,
END OF temp.
data:I type i value 1.
data:begin of itab1 occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
werks like vbrp-werks,
name1 like lfa1-name1,
lgort like mseg-lgort,
sloc like zmmstoragebin-storage,
bwart like mseg-bwart,
mblnr like mseg-mblnr,
zeile like mseg-zeile,
budat like bkpf-budat,
menge like mseg-menge,
meins like mara-meins,
end of itab1.
*Declarations for ALV.
TYPE-POOLS: slis.
DATA : itfieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA : itrepid TYPE sy-repid.
itrepid = sy-repid.
DATA : itevent TYPE slis_t_event.
DATA : itlistheader TYPE slis_t_listheader.
DATA : walistheader LIKE LINE OF itlistheader.
DATA : itlayout TYPE slis_layout_alv.
DATA : top TYPE slis_formname.
DATA : itsort TYPE slis_t_sortinfo_alv WITH HEADER LINE.
DATA : itsort1 TYPE slis_sortinfo_alv.
DATA : itprintparams TYPE slis_print_alv.
DATA : itvariant TYPE disvariant.
data : title type lvc_title.
field-symbols <fs> type LVC_TITLE.
concatenate 'Material Document List' ' ' into title separated by space.
assign title to <fs>.
perform submitmb51.
perform processfiller.
perform alv.
&----
*& Form submitmb51
&----
text
----
--> p1 text
<-- p2 text
----
form submitmb51 .
submit RM07DOCS EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
LISTOBJECT = LIST_TAB
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC = 0.
CALL FUNCTION 'LIST_TO_ASCI'
EXPORTING
LIST_INDEX = -1
TABLES
LISTASCI = oLIST
LISTOBJECT = LIST_TAB
EXCEPTIONS
EMPTY_LIST = 1
LIST_INDEX_INVALID = 2
OTHERS = 3.
ENDIF.
endform. " submitmb51
&----
*& Form processfiller
&----
text
----
--> p1 text
<-- p2 text
----
form processfiller .
*Deleteing the Junk Characters
loop at olist.
if sy-tabix >= 5 and
olist-filler1 <> '---' .
move-corresponding olist to temp.
append temp.
endif.
endloop.
*Creating Internal table
loop at temp.
i = i + 1.
itab1-matnr = temp-filler1+1(18).
itab1-maktx = temp-filler1+18(40).
itab1-werks = temp-filler1+61(4).
itab1-name1 = temp-filler1+66(29).
read table temp index i.
itab1-lgort = temp-filler1+1(4).
itab1-bwart = temp-filler1+6(3).
itab1-mblnr = temp-filler1+12(10).
itab1-zeile = temp-filler1+23(04).
append itab1.
clear temp.
endloop.
In the same way I want to fill the rest of the fields but I am having a problem when there is more than one material.
endform. " processfiller
&----
*& Form alv
&----
text
----
--> p1 text
<-- p2 text
----
form alv .
IF itab1[] IS INITIAL.
MESSAGE 'No Values exist for the Selection.' TYPE 'S'.
ELSE.
DEFINE m_fieldcat.
itfieldcat-fieldname = &1.
itfieldcat-col_pos = &2.
itfieldcat-seltext_l = &3.
itfieldcat-do_sum = &4.
itfieldcat-outputlen = &5.
itfieldcat-edit = &6.
append itfieldcat to itfieldcat.
clear itfieldcat.
END-OF-DEFINITION.
*MSEG
m_fieldcat 'MBLNR' '' 'Material Doc.No' '' 10 ''.
m_fieldcat 'MJAHR' '' 'Mat.Doc.Yr' '' 04 ''.
m_fieldcat 'ZEILE' '' 'Item in Mat.Doc' '' 04 ''.
m_fieldcat 'BWART' '' 'Movement Type' '' 03 ''.
m_fieldcat 'MATNR' '' 'Material' '' 18 ''.
m_fieldcat 'WERKS' '' 'Plant' '' 04 ''.
m_fieldcat 'LGORT' '' 'Storage Location' '' 04 ''.
m_fieldcat 'CHARG' '' 'Batch' '' 10 ''.
m_fieldcat 'SOBKZ' '' 'Spcl Stock Indicator' '' 01 ''.
m_fieldcat 'LIFNR' '' 'Vendor No.' '' 10 ''.
m_fieldcat 'NAME1' '' 'Vendor Name' '' 40 ''.
m_fieldcat 'KDAUF' '' 'Sales Order No.' '' 10 ''.
m_fieldcat 'SHKZG' '' 'Debit/Credit.' '' 01 ''.
m_fieldcat 'WAERS' '' 'Currency.' '' 03 ''.
m_fieldcat 'DMBTR' '' 'Amnt in Loc.Curr' '' 13 ''.
m_fieldcat 'BWTAR' '' 'Valutation Type' '' 10 ''.
m_fieldcat 'MENGE' '' 'Quantity' '' 13 ''.
m_fieldcat 'MEINS' '' 'Base UoM' '' 06 ''.
m_fieldcat 'ERFMG' '' 'Qty in UoE ' '' 10 ''.
m_fieldcat 'ERFME' '' 'Unit of Entry' '' 10 ''.
m_fieldcat 'EBELN' '' 'Purchase Order' '' 10 ''.
m_fieldcat 'EBELP' '' 'Purchase Ord Item' '' 05 ''.
m_fieldcat 'KOSTL' '' 'Cost Center' '' 10 ''.
m_fieldcat 'AUFNR' '' 'Order No.' '' 10 ''.
m_fieldcat 'ANLN1' '' 'Main Asset No.' '' 10 ''.
m_fieldcat 'ANLN2' '' 'Asset Sub Number' '' 10 ''.
m_fieldcat 'BUKRS' '' 'Company Code' '' 04 ''.
m_fieldcat 'RSNUM' '' 'Reservation No.' '' 04 ''.
m_fieldcat 'KZBEW' '' 'Movement Indicator' '' 01 ''.
m_fieldcat 'KZVBR' '' 'Consumption Posting' '' 01 ''.
m_fieldcat 'KZZUG' '' 'Receipt Indicator' '' 01 ''.
m_fieldcat 'PS_PSP_PNR' '' 'WBS Element' '' 04 ''.
m_fieldcat 'BSTMG' '' 'Qty in Order Unit' '' 03 ''.
m_fieldcat 'BSTME' '' 'Order Unit' '' 03 ''.
m_fieldcat 'BTEXT' '' 'Movement Type Text' '' 20 ''.
m_fieldcat 'MAKTX' '' 'Material Description' '' 40 ''.
m_fieldcat 'BWTAR' '' 'Valuation Type' '' 03 ''.
*MKPF
m_fieldcat 'VGART' '' 'Transctn/Evnt Typ' '' 03 ''.
m_fieldcat 'BLDAT' '' 'Document Date' '' 08 ''.
m_fieldcat 'BUDAT' '' 'Posting Date' '' 08 ''.
m_fieldcat 'CPUDT' '' 'Entry Date' '' 08 ''.
m_fieldcat 'USNAM' '' 'User Name.' '' 18 ''.
m_fieldcat 'XBLNR' '' 'Ref.Doc.No' '' 25 ''.
m_fieldcat 'BKTXT' '' 'Doc.Header Text' '' 25 ''.
m_fieldcat 'XABLN' '' 'GR/GI Slip No.' '' 10 ''.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = itlayout
i_callback_user_command = ' '
I_GRID_TITLE = <fs>
i_callback_top_of_page = ' '
it_fieldcat = itfieldcat[]
i_save = 'A'
it_events = itevent[]
it_sort = itsort[]
TABLES
t_outtab = itab1
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
endform. " alv
I want to create an internal table having the MB51 output as data.Can anyone here let me know how to go further.
2008 Feb 19 3:34 AM
data: begin of itab_enh.
include structure itab1.
field1 type table-field.
field2 type table-field.
data: end of itab_enh.
use this itab_enh in reuse FM
"this is a macro... defining here... similar to form.. in subroutine..
DEFINE m_fieldcat.
itfieldcat-fieldname = &1.
itfieldcat-col_pos = &2.
itfieldcat-seltext_l = &3.
itfieldcat-do_sum = &4.
itfieldcat-outputlen = &5.
itfieldcat-edit = &6.
append itfieldcat to itfieldcat.
clear itfieldcat.
END-OF-DEFINITION.
"calling the macro with fields
&1 = MBLNR
&2 = blank "<<no value
&3 = Material Doc.No
&4 = blank "<<no value
&5 = blank "<<no value
&6 = 10
m_fieldcat 'MBLNR' '' 'Material Doc.No' '' 10 ''.
and finally appending to the field catalog table
2008 Feb 19 3:39 AM
Jay,
I didn't get what you mean to say by defining a macro for the fieldcat which can be used merely for display.I am having a problem in creating an internal table having the MB51 output as data.Can you please be clear on what you mean to say.
Thanks,
K.Kiran.
2008 Aug 21 6:08 AM
Hi,
Did you find a way to add new fields to the ALV table in MB51?
We have the same requirement and are struggling to find how this can be achieved.
Many thxs Steve
2008 Aug 21 6:23 AM
Stephen,
Yes we did and it is working fine.
If you want add a new field in the selection screen then follow as per the link
http://www.sap123.com/showthread.php?p=359
If you want to add news field in the ALV and populate them based on some logic then we need to change the code but beaware there is a section of code which is not supposed to be changed manually.
The INCLUDE RM07DOCS_GENERATED I had used as it is because the Code is a GENERATED one and shouldn't be changed manually I guess.
I had copied the INCLUDE RM07ALVI and RM07DOCS_CONTROL as ZRM07ALVI and ZRMO7D0CS_CONTROL without any changes.
RM07DOCS I had copied as ZRM07DOCS and then went ahead with the changes as per the requirement.The final internal table which is having all the fields is LIST.So I have taken one more internal table say ITFINAL of the same structure but with three more new fields and processing this final internal table for the final output.
Ignore the code I had pasted in the above thread as it is just a crude piece of code and not the working one.
Revert if you have any queries.
K.Kiran.
2008 Sep 24 5:39 PM
Hi Kiran.
Can you please elaborate more on the above mentioned solution.
Thanks
Rahul.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |