Char10 to date
The date I have is Char10 '10/31/2007', When I display this in an ALV report and export it using excel, it gives out a dump at conversion when trying to interpret it as a number.
I need to convert it to a date. How to do this.
Megan,
I believe that Func Mod CONVERT_DATE_TO_INTERNAL will meet your needs.
If you don't want to use a FM, you could custom code it as well.
Something like:
data: n_date like sy-datum.
data: old_date(10).
old_date = '10/31/2007'.
concatenate old_date6(4) old_date0(2) old_date+3(2) into n_date.
Similar Messages
-
Data types pls..
Hi All,
What are all the data types we have, let me know each data type purpose pls....
Akshitha.Data types describe the technical attributes of data objects. They are purely descriptive and do not take up any memory space
Data Types in the ABAP Dictionary
The ABAP Dictionary allows you to define global data types. You can use the TYPE addition of an appropriate ABAP statement to refer to these data types in any ABAP program in the system.
There are three groups on the initial screen:
Database Tables and Views
One of the most important tasks of the ABAP Dictionary is to administer database tables in the R/3 database. The Dictionary contains metadescriptions of the database tables, and uses these to create the physical tables in the database. A view is a "virtual table" containing fields from one or more tables.
In the description of a database table, the table lines consist of single fields or columns. An elementary data type must be assigned to each column. The elementary types in the ABAP Dictionary are data elements. Like data objects in ABAP programs, database tables and views have data types as attributes. A line of a database table or view has the data type of a flat structure, which consists of individual data elements.
In ABAP programs, you can use the TYPE addition with the data type of a database table or view. You may refer to the whole structure or to individual components:
... TYPE <dbtab> ...
refers to the complex data type of the structure,
... TYPE <dbtab>-<ci> ...
refers to the elementary data type of component <ci>.
If you define a complex data type <t> as a structure using
TYPES <t> TYPE <dbtab>.
the components of the data type <t> inherit the names of the components of the database table or view, and can be addressed in the program using <t>-<ci>.
To ensure compatibility with previous releases, you can still use the LIKE addition to refer to database tables or views, except within classes. The reason for this is that in earlier releases, the physical presence of the database tables as objects was emphasized, even though the Dictionary only contains metadescriptions and data types.
Defining program-local data types by referring to database tables and views is one of the essential techniques for processing data from database tables in ABAP. Data objects that you define in this way always have the right type to contain data from the corresponding database table. ABAP Open SQL allows you to read a single field, a range of fields, or an entire database table or view into an internal table.
TYPES: city type spfli-cityfrom,
spfli_type TYPE STANDARD TABLE OF spfli WITH DEFAULT KEY.
DATA: wa_city TYPE city,
wa_spfli TYPE spfli_type.
SELECT SINGLE cityfrom FROM spfli
INTO wa_city
WHERE carrid = 'LH' AND connid = '400'.
SELECT * FROM spfli INTO TABLE wa_spfli.
This example defines an elementary data type CITY that refers to a single field of the database table SPFLI and an internal table SPFLI_TYPE, whose line type is the same as the structure of the database table. The SELECT statement reads data from the database into the corresponding data objects.
Data types
Data types are the actual type definitions in the ABAP Dictionary. They allow you to define elementary types, reference types, and complex types that are visible globally in the system. The data types of database tables are a subset of all possible types, namely flat structures. Global object types (classes and interfaces) are not stored in the ABAP Dictionary, but in the class library. You create them using the Class Builder.
For a detailed description of data types and their definitions, refer to the Types section of the ABAP Dictionary documentation. The following descriptions mention the types only briefly, along with how you can refer to them from ABAP programs.
Data Elements
Data elements in the ABAP Dictionary describe individual fields. They are the smallest indivisible units of the complex types described below, and are used to specify the types of columns in the database. Data elements can be elementary types or reference types.
Elementary Types
Elementary types are part of the dual-level domain concept for fields in the ABAP Dictionary. The elementary type has semantic attributes, such as texts, value tables, and documentation, and has a data type. There are two different ways to specify a data type:
By directly assigning an ABAP Dictionary type.
You can assign a predefined ABAP Dictionary type and a number of characters to an elementary type. The ABAP Dictionary has considerably more predefined types than the ABAP programming language. The number of characters here is not the field length in bytes, but the number of valid characters excluding formatting characters. The data types are different because the predefined data types in the ABAP Dictionary have to be compatible with the external data types of the database tables supported by the R/3 System.
When you refer to data types from the ABAP Dictionary in an ABAP program, the predefined Dictionary types are converted to ABAP types as follows:
Dictionary type
Meaning
Maximum length n
ABAP type
DEC
Calculation/amount field
1-31, 1-17 in tables
P((n+1)/2)
INT1
Single-byte integer
3
Internal only
INT2
Two-byte integer
5
Internal only
INT4
Four-byte integer
10
I
CURR
Currency field
1-17
P((n+1)/2)
CUKY
Currency key
5
C(5)
QUAN
Amount
1-17
P((n+1)/2)
UNIT
Unit
2-3
C(n)
PREC
Accuracy
2
X(2)
FLTP
Floating point number
16
F(8)
NUMC
Numeric text
1-255
N(n)
CHAR
Character
1-255
C(n)
LCHR
Long character
256-max
C(n)
STRING.
String of variable length
1-max
STRING.
RAWSTRING
Byte sequence of variable length
1-max
XSTRING
DATS
Date
8
D
ACCP
Accounting period YYYYMM
6
N(6)
TIMS
Time HHMMSS
6
T
RAW
Byte sequence
1-255
X(n)
LRAW
Long byte sequence
256-max
X(n)
CLNT
Client
3
C(3)
LANG
Language
internal 1, external 2
C(1)
("max" in LCHR and LRAW is the value of a preceding INT2 field. The "internal" length of a LANG field is in the Dictionary, the "external" length refers to the display on the screen.
Assigning a domain
The technical attributes are inherited from a domain. Domains are standalone Repository objects in the ABAP Dictionary. They can specify the technical attributes of a data element. One domain can be used by any number of data elements. When you create a domain, you must specify a Dictionary data type (see above table) and the number of characters.
Reference Types
Reference types describe single fields that can contain references to global classes and interfaces from the ABAP class library.
In an ABAP program, you can use the TYPE addition to refer directly to a data element. The predefined Dictionary data types of the domain are then converted into the corresponding ABAP types.
If you define a local data type in a program by referring to a data element as follows:
TYPES <t> TYPE <data element>.
the semantic attributes of the data element are inherited and will be used, for example, when you display a data object with type <t> on the screen. Since all data types in the ABAP Dictionary are based on data elements, they all contain the corresponding semantic attributes.
TYPES company TYPE s_carr_id.
DATA wa_company TYPE company.
wa_company = 'UA '.
WRITE: 'Company:', wa_company.
This example defines a local type COMPANY that refers to the data element S_CARR_ID. The data element is linked to the identically-named domain S_CARR_ID. The domain defines the technical attributes as data type CHAR with length 3. The local data type COMPANY in the program therefore has the ABAP type C(3). COMPANY also adopts the semantic attributes of the data element. In the above example, we declare a data object WA_COMPANY with this type and display it on a list. If the user chooses F1 help for the output field, the help text stored in the ABAP Dictionary will appear in a dialog box.
Structures
A structure is a sequence of any other data types from the ABAP Dictionary, that is, data elements, structures, table types, or database tables. When you create a structure in the ABAP Dictionary, each component must have a name and a data type.
In an ABAP program, you can use the TYPE addition to refer directly to a structure.
If you define a local data type in a program by referring to a structure as follows:
TYPES <t> TYPE <structure>.
the construction blueprint of the structure is used to create a local structure <t> in the program. The predefined Dictionary data types of the domains used by the data elements in the structure are converted into the corresponding ABAP types. The semantic attributes of the data elements are used for the corresponding components of the structure in the program. The components of the local structure <t> have the same names as those of the structure in the ABAP Dictionary.
To ensure compatibility with previous releases, it is still possible to use the LIKE addition in an ABAP program to refer to a structure in the ABAP Dictionary (except in classes).
Suppose the structure STRUCT is defined as follows in the ABAP Dictionary:
Field name
Type name
Description
COL1
CHAR01
Character field with length 1
COL2
CHAR08
Character field with length 8
COL3
CHAR10
Character field with length 10
The types CHAR01 to CHAR10 are data elements with corresponding domains. We can refer to this structure in ABAP:
TYPES struct_type TYPE struct.
DATA wa TYPE struct_type.
wa-col1 = '1'.
wa-col2 = '12345678'.
wa-col3 = '1234567890'.
This program creates a local structure in the program - STRUCT_TYPE - and a corresponding data object WA. We can address the components using the component names from the original structure.
Table Types
Table types are construction blueprints for internal tables that are stored in the ABAP Dictionary. When you create a table type in the ABAP Dictionary, you specify the line type, access type, and key. The line type can be any data type from the ABAP Dictionary, that is, a data element, a structure, a table type, or the type of a database table. You can also enter a predefined Dictionary type directly as the line type, in the same way that you can with a domain.
In an ABAP program, you can use the TYPE addition to refer directly to a table type.
If you define a local data type in a program by referring to a table type as follows:
TYPES <t> TYPE <table>.
the construction blueprint of the table type is used to create a local internal table <t> in the program. The predefined Dictionary data types of the domains used by the data elements in the structure are converted into the corresponding ABAP types. The semantic attributes of the data elements are used for the corresponding components of the internal table in the program.
Suppose the table type STRUCT_TABLE is defined in the Dictionary with the line type STRUCT from the previous example. We can refer to this in ABAP:
TYPES table_type TYPE struct_table.
DATA: table_wa TYPE table_type,
line_wa LIKE LINE OF table_wa.
LOOP AT table_wa INTO line_wa.
WRITE: line_wa-col1, line_wa-col1, line_wa-col1.
ENDLOOP.
This program defines an internal table type TABLE_TYPE. From it, we define data objects TABLE_WA and LINE_WA. LINE_WA corresponds to the line type of the table type in the Dictionary, and is therefore compatible with the structure STRUCT.
Type Groups
Before Release 4.5A, it was not possible to define standalone types in the ABAP Dictionary to which you could refer using a TYPE addition in an ABAP program. It was only possible to refer to flat structures. Structures in programs corresponded to the structures of database tables or structures in the ABAP Dictionary. In ABAP programs, you could only refer to database tables and structures in the ABAP Dictionary using LIKE. It was, however, possible to refer to individual components of the Dictionary type. Complex local data types such as internal tables or deep structures had no equivalent in the ABAP Dictionary. The solution to this from Release 3.0 onwards was to use type groups. Type groups were based on the include technique, and allowed you to store any type definitions globally in the Dictionary by defining them using TYPES statements.
The definition of a type group is a fragment of ABAP code which you enter in the ABAP Editor. The first statement for the type group <pool> is always:
TYPE-POOL <pool>.
After this came the definitions of data types using the TYPES statement, as described in Local Data Types in Programs. It was also possible to define global constants using the CONSTANTS statement. All the names of these data types and constants must begin with the name of the type group and an underscore:
In an ABAP program, you must declare a type group as follows before you can use it:
TYPE-POOLS <pool>.
This statement allows you to use all the data types and constants defined in the type group <pool> in your program. You can use several type groups in the same program.
Let the type group HKTST be created as follows in the ABAP Dictionary:
TYPE-POOL hktst.
TYPES: BEGIN OF hktst_typ1,
col1(10) TYPE c,
col2 TYPE i,
END OF hktst_typ1.
TYPES hktst_typ2 TYPE p DECIMALS 2.
CONSTANTS hktst_eleven TYPE i VALUE 11.
This type group defines two data types HKTST_TYP1 and HKTST_TYP2, as well as a constant HKTST_ELEVEN with the value 11.
Any ABAP program can use these definition by including a TYPE-POOLS statement:
TYPE-POOLS hktst.
DATA: dat1 TYPE hktst_typ1,
dat2 TYPE hktst_typ2 VALUE '1.23'.
WRITE: dat2, / hktst_eleven.
The output is:
1,23
11
The data types defined in the type group are used to declare data objects with the DATA statement and the value of the constant is, as the output shows, known in the program. -
Call transaction error handling
how to maintain the log i.e sucess/failures like below.
Line No. Success/ Failure Document No Error Details
1 S Doc 740000001
2 S Doc 740000002
3 F Co- code does not exist
4 F GL Account does not exist
I'm getting only one last document no: but i need all the documents to be displayed i.e either success/failures.
below is my code.
TYPES: BEGIN OF ty_filedata,
bukrs TYPE bukrs, "Company code
blart TYPE blart, "Document type
bldat TYPE char10, "Document Date
budat TYPE char10, "Posting date
xblnr TYPE xblnr, "Reference
bktxt TYPE bktxt, "Document Header text
waers TYPE waers, "Currency
newbs TYPE bschl, "Posting Key for the next line item
wrbtr TYPE char10, "Amount
zuonr LIKE bsik-zuonr, "Assignment
sgtxt TYPE sgtxt, "Text
newko TYPE hkont, "Account for the next line item
END OF ty_filedata.
TYPES: BEGIN OF ty_detail_log,
item_no TYPE i, " Item line no.
status(1) TYPE c, " Status - success/failure
doc_no TYPE bkpf-belnr," Document No.
message TYPE string, " Message
END OF ty_detail_log.
*& DATA declaration of internal tables
Internal Table declaration for excel data
DATA: it_itab TYPE STANDARD TABLE OF alsmex_tabline INITIAL SIZE 0,
Internal Table declaration for upload data
it_upload TYPE STANDARD TABLE OF ty_filedata INITIAL SIZE 0,
Internal Table Declaration for BDCDATA
it_bdcdata TYPE STANDARD TABLE OF bdcdata,
Internal Table Declaration for BDCMSGCOLL
it_bdcmsgcoll TYPE STANDARD TABLE OF bdcmsgcoll,
Internal Table Declaration for FILENMAE
lf_fname TYPE rlgrap-filename.
t_err_log TYPE STANDARD TABLE OF ty_err
INITIAL SIZE 0, " table for validation error log
t_DETAIL_LOG TYPE STANDARD TABLE OF TY_DETAIL_LOG.
C_MSGNO TYPE BDC_MNR VALUE '312',
*& DATA declaration of work area
Work Area declaration for Excel Data
DATA: w_itab TYPE alsmex_tabline,
Work Area declaration for upload data
w_upload TYPE ty_filedata,
Work Area declaration for upload data
w_upload_n TYPE ty_filedata,
Work Area declaration for upload data
w_bdcdata TYPE bdcdata,
Work Area declaration for upload data
w_bdcmsgcoll TYPE bdcmsgcoll,
w_detail_log TYPE ty_detail_log.
*& SELECTION-SCREEN
SELECTION-SCREEN: BEGIN OF BLOCK bk1 WITH FRAME TITLE text-001.
PARAMETERS:p_file TYPE rlgrap-filename. " MODIF ID G1.
SELECTION-SCREEN: END OF BLOCK bk1.
*& AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
dynpro_number = syst-dynnr
CHANGING
file_name = p_file
EXCEPTIONS
mask_too_long = 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.
*& START-OF-SELECTION
START-OF-SELECTION.
DATA: lw_itab TYPE alsmex_tabline.
lf_fname = p_file.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = lf_fname
i_begin_col = '1'
i_begin_row = '6'
i_end_col = '12'
i_end_row = '999'
TABLES
intern = it_itab[]
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
*MESSAGE S205(ZF_COMMON_MSGS_FIN1) DISPLAY LIKE C_E.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ELSE.
IF it_itab IS NOT INITIAL.
SORT it_itab BY row col.
DELETE it_itab WHERE row LT 6.
LOOP AT it_itab INTO lw_itab.
w_itab = lw_itab.
AT NEW row.
CLEAR: w_upload.
ENDAT.
CASE w_itab-col.
WHEN '0001'.
w_upload-bukrs = w_itab-value.
WHEN '0002'.
w_upload-blart = w_itab-value.
WHEN '0003'.
w_upload-bldat = w_itab-value.
WHEN '0004'.
w_upload-budat = w_itab-value.
WHEN '0005'.
w_upload-xblnr = w_itab-value.
WHEN '0006'.
w_upload-bktxt = w_itab-value.
WHEN '0007'.
w_upload-waers = w_itab-value.
WHEN '0008'.
w_upload-newbs = w_itab-value.
WHEN '0009'.
w_upload-wrbtr = w_itab-value.
WHEN '0010'..
w_upload-zuonr = w_itab-value.
WHEN '0011'.
w_upload-sgtxt = w_itab-value.
WHEN '0012'.
w_upload-newko = w_itab-value.
ENDCASE.
AT END OF row.
APPEND w_upload TO it_upload.
CLEAR: w_upload.
ENDAT.
ENDLOOP.
*endif.
ENDIF.
DATA: lw_upload TYPE ty_filedata,
lv_lines TYPE sy-tabix,
lv_index TYPE sy-tabix.
DESCRIBE TABLE it_upload LINES lv_lines.
LOOP AT it_upload INTO lw_upload.
lv_index = sy-tabix.
w_upload = lw_upload.
IF NOT w_upload-bukrs IS INITIAL.
IF lv_index GT 1.
CALL TRANSACTION 'FB01' USING it_bdcdata
MODE 'N' UPDATE 'S' MESSAGES INTO it_bdcmsgcoll.
PERFORM fr_format_message_text.
REFRESH: it_bdcdata.
ENDIF.
PERFORM bdc_dynpro USING 'SAPMF05A' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'BKPF-XBLNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BKPF-BLDAT'
w_upload-bldat.
PERFORM bdc_field USING 'BKPF-BLART'
w_upload-blart.
PERFORM bdc_field USING 'BKPF-BUKRS'
w_upload-bukrs.
PERFORM bdc_field USING 'BKPF-BUDAT'
w_upload-budat.
PERFORM bdc_field USING 'BKPF-WAERS'
w_upload-waers.
PERFORM bdc_field USING 'BKPF-XBLNR'
w_upload-xblnr.
*perform bdc_field using 'FS006-DOCID'
PERFORM bdc_field USING 'RF05A-NEWBS'
w_upload-newbs.
PERFORM bdc_field USING 'RF05A-NEWKO'
w_upload-newko.
ENDIF.
IF lv_index NE lv_lines.
lv_index = lv_index + 1.
READ TABLE it_upload INTO w_upload_n INDEX lv_index.
PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.
PERFORM bdc_field USING 'BDC_CURSOR'
'BSEG-WRBTR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BSEG-WRBTR'
w_upload-wrbtr.
PERFORM bdc_field USING 'RF05A-NEWBS'
w_upload_n-newbs.
PERFORM bdc_field USING 'RF05A-NEWKO'
w_upload_n-newko.
ELSE.
PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.
PERFORM bdc_field USING 'BDC_CURSOR'
'BSEG-WRBTR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
PERFORM bdc_field USING 'BSEG-WRBTR'
w_upload-wrbtr.
ENDIF.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_CURSOR'
'COBL-ANLN1'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTE'.
ENDLOOP.
CALL TRANSACTION 'FB01' USING it_bdcdata
MODE 'N' UPDATE 'S' MESSAGES INTO it_bdcmsgcoll.
PERFORM fr_format_message_text .
REFRESH: it_bdcdata.
*& Form BDC_DYNPRO
FORM bdc_dynpro USING program dynpro.
CLEAR w_bdcdata.
w_bdcdata-program = program.
w_bdcdata-dynpro = dynpro.
w_bdcdata-dynbegin = 'X'.
APPEND w_bdcdata TO it_bdcdata.
ENDFORM. "BDC_DYNPRO
Insert field *
FORM bdc_field USING fnam fval.
IF fval <> space.
CLEAR w_bdcdata.
w_bdcdata-fnam = fnam.
w_bdcdata-fval = fval.
APPEND w_bdcdata TO it_bdcdata.
ENDIF.
ENDFORM. "BDC_FIELD
*& Form fr_format_message_text
FORM fr_format_message_text.
DATA: lf_msg TYPE string.
WRITE:/ sy-uline(125).
FORMAT COLOR 1 INTENSIFIED ON.
WRITE : /1 sy-vline,
2 text-041 , "'record Number',
16 sy-vline,
17 text-042 , " 'success/failure',
35 sy-vline,
36 text-043, " 'document no',
55 sy-vline,
56 text-044, "'Error details',
125 sy-vline.
WRITE:/ sy-uline(125).
LOOP AT it_bdcmsgcoll INTO w_bdcmsgcoll.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = w_bdcmsgcoll-msgid
lang = sy-langu
no = w_bdcmsgcoll-msgnr
v1 = w_bdcmsgcoll-msgv1
v2 = w_bdcmsgcoll-msgv2
v3 = w_bdcmsgcoll-msgv3
v4 = w_bdcmsgcoll-msgv4
IMPORTING
msg = lf_msg
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc EQ 0.
WRITE:/01 sy-vline,
02 sy-tabix,
16 sy-vline,
17 w_bdcmsgcoll-msgtyp,
35 sy-vline,
36 w_bdcmsgcoll-msgv1,
55 sy-vline,
56 lf_msg,
125 sy-vline.
WRITE:/ sy-uline(125).
ENDIF.
ENDLOOP.
ENDFORM. "fr_format_message_text
Thanks in advance.Hi Neelima,
Just put the following code within that LOOP...ENDLOOP statement.
LOOP AT it_upload INTO lw_upload.
CALL TRANSACTION 'FB01' USING it_bdcdata
MODE 'N' UPDATE 'S' MESSAGES INTO it_bdcmsgcoll.
PERFORM fr_format_message_text .
REFRESH: it_bdcdata.
ENDLOOP.
Regards,
R.Nagarajan.
We can - -
How to parameter F4IF_INT_TABLE_VALUE_REQUEST?
Hi experts,
could u explain, what are the parameters in this function? I tried to parameter the function, but no value found and nothing was displayed.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
ddic_structure = '
retfield = ' '
PVALKEY = ' '
DYNPPROG = ' '
DYNPNR = ' '
DYNPROFIELD = ' '
STEPL = 0
WINDOW_TITLE =
VALUE = ' '
VALUE_ORG = 'C'
MULTIPLE_CHOICE = ' '
DISPLAY = ' '
CALLBACK_PROGRAM = ' '
CALLBACK_FORM = ' '
TABLES
value_tab =
FIELD_TAB =
RETURN_TAB =
DYNPFLD_MAPPING =hi,try this code
SELECT-OPTIONS: s_f4 for wa_tab-f1.
INITIALIZATION.
PERFORM get_search_hlp_values.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_f4-low.
PERFORM get_f4help CHANGING s_f4-low.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_f4-high.
PERFORM sub_get_f4help CHANGING s_f4-high.
FORM get_search_hlp_values.
fill itab with values here
ENDFORM. " sub_get_search_hlp_values
FORM sub_get_f4help_for_user CHANGING p_bname TYPE char10.
DATA: l_i_field TYPE STANDARD TABLE OF dfies INITIAL SIZE 0,
l_wa_field TYPE dfies,
l_i_return TYPE TABLE OF ddshretval,
l_wa_return TYPE ddshretval.
CONSTANTS: c_feild TYPE dfies-fieldname VALUE 'BNAME',
c_dynprg TYPE sy-repid VALUE 'RSSYSTBD',
c_dynpnr TYPE sy-dynnr VALUE '1000',
c_dynfeild TYPE help_info-dynprofld VALUE 'S_BNAME-LOW',
c_stepl TYPE sy-stepl VALUE '0',
c_valueorg TYPE ddbool_d VALUE 'C'.
Populate the Field table
l_wa_field-tabname = 'QMFE'.
l_wa_field-fieldname = 'FECOD'.
APPEND l_wa_field TO l_i_field.
IF NOT i_data[] IS INITIAL.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = c_feild
dynpprog = c_dynprg
dynpnr = c_dynpnr
stepl = c_stepl
value_org = c_valueorg
TABLES
value_tab = i_tab
field_tab = l_i_field
return_tab = l_i_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
READ TABLE l_i_return INTO l_wa_return
WITH KEY fieldname = 'FECOD'.
IF sy-subrc EQ 0.
p_bname = l_wa_return-fieldval.
ENDIF.
ENDIF.
ENDFORM. " get_F4help
thanks -
In a dialog program I"m using the 'on value request' to call a routine that builds a dropdown on a field. It looks like this:
PROCESS ON VALUE-REQUEST.
FIELD ekpo_ci-zzlicnum module build_search.
Within build_search, I build itab_values with the dropdown values and the function module is called:
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING RETFIELD = 'ZZLICNUM'
DYNPPROG = w_progname
DYNPNR = w_scr_num
DYNPROFIELD = 'ZZLICNUM'
VALUE_ORG = 'S'
TABLES
VALUE_TAB = ITAB_VALUES
RETURN_TAB = RETURN_VALUES
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3.
The routine calls F4IF_INT_TABLE_VALUE_REQUEST and in the dropdown, 5 fields are shown in each row (built in an internal table itab_values). When I select one of the rows, it returns the field value for zzlicnum in return_values. Is there a way to also return the other values I have in itab_values (other than just zzlicnum) - I need to use the other fields that are associated with zzlicnum in my program for some additional logic.
I appreciate any help!hi,
refer to these codes:
you can change something according to your requirement.
PARAMETERS:
a TYPE char10,
b TYPE char10,
c TYPE char10.
DATA:
BEGIN OF tab OCCURS 0,
field1 TYPE char10,
field2 TYPE char10,
field3 TYPE char10,
END OF tab,
wa LIKE LINE OF tab,
DYNPFLD_MAPPING TYPE STANDARD TABLE OF DSELC,
dyn_wa TYPE DSELC,
lt_return TYPE TABLE OF DDSHRETVAL,
lwa_return TYPE ddshretval.
INITIALIZATION.
wa-field1 = 'aaaaa'.
wa-field2 = 'bbbbb'.
wa-field3 = 'ccccc'.
APPEND wa to tab.
wa-field1 = 'aaaaa'.
wa-field2 = 'bbccc'.
wa-field3 = 'ddddd'.
APPEND wa to tab.
wa-field1 = 'aaaab'.
wa-field2 = 'bbccc'.
wa-field3 = 'eeeee'.
APPEND wa to tab.
dyn_wa-FLDNAME = 'FIELD1'.
dyn_wa-DYFLDNAME = 'A'.
APPEND dyn_wa to DYNPFLD_MAPPING.
dyn_wa-FLDNAME = 'FIELD2'.
dyn_wa-DYFLDNAME = 'B'.
APPEND dyn_wa to DYNPFLD_MAPPING.
dyn_wa-FLDNAME = 'FIELD3'.
dyn_wa-DYFLDNAME = 'C'.
APPEND dyn_wa to DYNPFLD_MAPPING.
AT SELECTION-SCREEN on VALUE-REQUEST FOR a.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
* DDIC_STRUCTURE = ' '
retfield = 'FIELD1'
* PVALKEY = ' '
DYNPPROG = sy-cprog
DYNPNR = '1000'
DYNPROFIELD = 'A'
* STEPL = 0
* WINDOW_TITLE = WINDOW_TITLE
* VALUE = ' '
VALUE_ORG = 'S'
* MULTIPLE_CHOICE = ' '
* DISPLAY = ' '
CALLBACK_PROGRAM = sy-cprog
CALLBACK_FORM = 'CALLBACK_F4'
* MARK_TAB = MARK_TAB
* IMPORTING
* USER_RESET = USER_RESET
TABLES
value_tab = tab
* FIELD_TAB = FIELD_TAB
RETURN_TAB = lt_return
* DYNPFLD_MAPPING = DYNPFLD_MAPPING
* 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.
form callback_f4 TABLES record_tab STRUCTURE seahlpres
CHANGING shlp TYPE shlp_descr
callcontrol LIKE ddshf4ctrl.
DATA:
ls_intf LIKE LINE OF shlp-interface,
ls_prop LIKE LINE OF shlp-fieldprop.
*Hide unwanted fields
CLEAR: ls_prop-shlpselpos,
ls_prop-shlplispos.
* MODIFY shlp-fieldprop FROM ls_prop
* TRANSPORTING shlpselpos shlplispos
* WHERE ( fieldname NE 'F0001' AND
* fieldname NE 'F0002' AND
* fieldname NE 'F0003' ).
* " Overwrite selectable fields on search help
REFRESH: shlp-interface.
ls_intf-shlpfield = 'F0001'.
ls_intf-valfield = 'A'.
ls_intf-f4field = 'X'.
APPEND ls_intf TO shlp-interface.
ls_intf-shlpfield = 'F0002'.
ls_intf-valfield = 'B'.
ls_intf-f4field = 'X'.
APPEND ls_intf TO shlp-interface.
ls_intf-shlpfield = 'F0003'.
ls_intf-valfield = 'C'.
ls_intf-f4field = 'X'.
APPEND ls_intf TO shlp-interface.
ENDFORM. -
Hi Experts,
i have issue were in i need to show sum of the amount. like example...
for Custmer 100 there are vendor number 10,20,30,40,50. so for all this vendor numbers..
vendor----- amount
10 -
100
20----
200
30----
300
40----
400
50-------500
so in the output i want it to be..
customer--vendornumber--
amount
1000--10--
1500
20---
30---
40---
50---
.hope u experts have undestood. so how can i add the it and show it in the output....
am forwarding my code also..
Corrects answers will be fully rewarded..
REPORT zrfi007 NO STANDARD PAGE HEADING LINE-SIZE 255 MESSAGE-ID z01.
TYPE-POOLS: slis, abap.
* TYPES Declaration
TYPES: BEGIN OF ty_lfa1,
lifnr TYPE lfa1-lifnr,
name1 TYPE lfa1-name1,
END OF ty_lfa1.
TYPES: BEGIN OF ty_bsik,
bukrs TYPE bsik-bukrs,
lifnr TYPE bsik-lifnr,
belnr TYPE bsik-belnr,
bldat TYPE bsik-bldat,
waers TYPE bsik-waers,
dmbtr TYPE bsik-dmbtr,
wrbtr TYPE bsik-wrbtr,
zfbdt TYPE bsik-zfbdt,
zbd1t TYPE bsik-zbd1t,
zbd2t TYPE bsik-zbd2t,
zbd3t TYPE bsik-zbd3t,
END OF ty_bsik.
TYPES: BEGIN OF ty_lfb1,
lifnr TYPE lfb1-lifnr,
bukrs TYPE lfb1-bukrs,
END OF ty_lfb1.
TYPES: BEGIN OF ty_final,
bukrs TYPE bsik-bukrs,
lifnr TYPE bsik-lifnr,
belnr TYPE bsik-belnr,
bldat TYPE bsik-bldat,
days TYPE sy-datum,
waers TYPE bsik-waers,
dmbtr TYPE bsik-dmbtr,
* waers type bsik-waers,
wrbtr TYPE bsik-wrbtr,
zfbdt TYPE bsik-zfbdt,
zbd1t TYPE bsik-zbd1t,
zbd2t TYPE bsik-zbd2t,
zbd3t TYPE bsik-zbd3t,
name1 TYPE lfa1-name1,
current TYPE bsik-dmbtr,
d30 TYPE bsik-dmbtr,
d60 TYPE bsik-dmbtr,
d90 TYPE bsik-dmbtr,
d120 TYPE bsik-dmbtr,
d180 TYPE bsik-dmbtr,
d240 TYPE bsik-dmbtr,
d360 TYPE bsik-dmbtr,
da365 TYPE bsik-dmbtr,
* ct_date TYPE sy-datum,
* date TYPE datum,
* days TYPE char8,
END OF ty_final.
* Data Declaration.
DATA: gt_lfa1 TYPE STANDARD TABLE OF ty_lfa1,
wa_lfa1 TYPE ty_lfa1.
DATA: gt_final TYPE STANDARD TABLE OF ty_final,
wa_final TYPE ty_final.
DATA: gt_bsik TYPE STANDARD TABLE OF ty_bsik,
wa_bsik TYPE ty_bsik.
DATA: gt_lfb1 TYPE STANDARD TABLE OF ty_lfb1,
wa_lfb1 TYPE ty_lfb1.
DATA: days TYPE sy-datum.
* ALV Components
**** ALV Internal Table
DATA : i_layout TYPE slis_layout_alv OCCURS 0 WITH HEADER LINE,
i_events TYPE slis_t_event,
i_fieldcat TYPE slis_t_fieldcat_alv,
i_print TYPE slis_print_alv,
i_list_top TYPE slis_t_listheader,
i_list_end TYPE slis_t_listheader,
i_sort TYPE slis_t_sortinfo_alv.
DATA: wa_fieldcat LIKE LINE OF i_fieldcat.
* ALV Variable.
DATA: v_top TYPE slis_formname VALUE 'TOP_OF_PAGE',
v_eop TYPE slis_formname VALUE 'END_OF_PAGE',
v_eol TYPE slis_formname VALUE 'END_OF_LIST',
v_tol TYPE slis_formname VALUE 'TOP_OF_LIST'.
**** ALV Variants
DATA: i_variant LIKE disvariant.
* Selection screen
DATA: v_bukrs TYPE bukrs,
v_lifnr TYPE kunnr,
pa_bldat TYPE bldat.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_bukrs FOR v_bukrs NO INTERVALS NO-EXTENSION OBLIGATORY,
s_lifnr FOR v_lifnr.
* bldat FOR v_bldat no-extension.
PARAMETERS: p_bldat TYPE bsik-bldat.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: p_detail RADIOBUTTON GROUP r1 DEFAULT 'X',
p_sumry RADIOBUTTON GROUP r1.
SELECTION-SCREEN END OF BLOCK b2.
* Top-Of-Page Declaration Header
DATA: lwa_list_top LIKE LINE OF i_list_top.
DATA: lv_header(70),
lv_text(50),
lv_text1(60),
lv_text2(50),
lv_text3(50) ,
lv_text4(50),
lv_date TYPE char10,
lv_time TYPE char10.
DATA: lv_butxt LIKE t001-butxt,
lv_butxt1 LIKE lfa1-name1,
lv_butxt2 LIKE lfb1-lifnr.
INITIALIZATION.
*TOP-OF-PAGE.
* Validations for Selection screen
AT SELECTION-SCREEN ON s_bukrs.
IF NOT s_bukrs[] IS INITIAL.
SELECT SINGLE bukrs FROM lfb1
INTO s_bukrs
WHERE bukrs IN s_bukrs.
ENDIF.
IF sy-subrc NE 0.
MESSAGE e003.
ENDIF.
AT SELECTION-SCREEN ON s_lifnr.
IF NOT s_lifnr[] IS INITIAL.
SELECT SINGLE lifnr FROM lfa1
INTO s_lifnr
WHERE lifnr IN s_lifnr.
IF sy-subrc NE 0.
MESSAGE e005.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON p_bldat.
IF NOT p_bldat IS INITIAL.
SELECT SINGLE bldat FROM bsid
INTO p_bldat
WHERE bldat = p_bldat.
IF sy-subrc NE 0 .
MESSAGE e004.
ENDIF.
ENDIF.
* Selection For Top-of-page.
** Get company code description
SELECT SINGLE butxt
FROM t001 INTO lv_butxt
WHERE bukrs IN s_bukrs.
* SELECT SINGLE lifnr FROM lfb1
* INTO lv_butxt2 WHERE bukrs IN s_bukrs.
* SELECT SINGLE name1 FROM lfa1
* INTO lv_butxt1 WHERE lifnr = lv_butxt2.
START-OF-SELECTION.
PERFORM data_retrival.
PERFORM f_layout_init.
PERFORM f_eventtab_build.
i_variant-report = sy-repid.
PERFORM f_print_control.
* PERFORM f_build_header_list.
* perform f_build_header_list1.
* PERFORM f_build_fieldcat.
IF p_detail = 'X'.
PERFORM f_build_sort.
PERFORM fill_fieldcat.
PERFORM f_build_header_list.
ELSE.
PERFORM f_build_sort1.
PERFORM fill_fieldcat_sum.
PERFORM f_build_header_list1.
ENDIF.
PERFORM f_list_display TABLES gt_final[].
END-OF-SELECTION.
*& Form data_retrival
* text
* --> p1 text
* <-- p2 text
FORM data_retrival .
SELECT bukrs
lifnr
belnr
bldat
waers
dmbtr
wrbtr
zfbdt
zbd1t
zbd2t
zbd3t
FROM bsik INTO TABLE gt_bsik
WHERE bukrs IN s_bukrs
AND lifnr IN s_lifnr.
SELECT lifnr
name1
FROM lfa1 INTO TABLE gt_lfa1
FOR ALL ENTRIES IN gt_bsik
WHERE lifnr = gt_bsik-lifnr.
LOOP AT gt_bsik INTO wa_bsik.
READ TABLE gt_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_bsik-lifnr.
MOVE-CORRESPONDING wa_bsik TO wa_final.
MOVE-CORRESPONDING wa_lfa1 TO wa_final.
DATA: days TYPE char2,
c4 TYPE char2.
DATA: days1 TYPE sy-datum.
DATA:duedate TYPE rfpos-faedt.
CALL FUNCTION 'NET_DUE_DATE_GET'
EXPORTING
i_zfbdt = wa_final-zfbdt
i_zbd1t = wa_final-zbd1t
i_zbd2t = wa_final-zbd2t
i_zbd3t = wa_final-zbd3t
i_shkzg = ' '
i_rebzg = ' '
* I_KOART = 'D'
IMPORTING
e_faedt = duedate.
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = duedate
i_datum_von = wa_final-bldat
* I_KZ_EXCL_VON = '0'
* I_KZ_INCL_BIS = '0'
* I_KZ_ULT_BIS = ' '
* I_KZ_ULT_VON = ' '
* I_STGMETH = '0'
* I_SZBMETH = '1'
IMPORTING
e_tage = days
EXCEPTIONS
days_method_not_defined = 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.
wa_final-days = duedate.
DATA : wf_char TYPE char10.
wf_char = days.
IF wf_char+0(1) EQ '*' .
SKIP.
ELSE.
IF days EQ 0.
wa_final-current = wa_bsik-wrbtr.
ELSEIF days LE 30 AND days GT 0.
wa_final-d30 = wa_bsik-wrbtr.
ELSEIF days LE 60 AND days GT 30 .
wa_final-d60 = wa_bsik-wrbtr.
ELSEIF days LE 90 AND days GT 60.
wa_final-d90 = wa_bsik-wrbtr.
ELSEIF days LE 120 AND days GT 90.
wa_final-d120 = wa_bsik-wrbtr.
ELSEIF days LE 180 AND days GT 120.
wa_final-d180 = wa_bsik-wrbtr.
ELSEIF days LE 240 AND days GT 180.
wa_final-d240 = wa_bsik-wrbtr.
ELSEIF days LE 360 AND days GT 240.
wa_final-d360 = wa_bsik-wrbtr.
ELSEIF days GT 365 .
wa_final-da365 = wa_bsik-wrbtr.
ENDIF.
ENDIF.
APPEND wa_final TO gt_final.
CLEAR: wa_final,
days,
duedate,days1.
ENDLOOP.
ENDFORM. " data_retrival
*& Form fill_fieldcat
* text
FORM fill_fieldcat.
PERFORM fill_fields USING: 'Vendor Number' 'LIFNR',
'Vendor Name' 'NAME1',
'Document Number' 'BELNR',
'Document Date' 'BLDAT',
'Due Date' 'DAYS',
'Total In Document Currency' 'WRBTR',
'Currency' 'WAERS',
'Total In Reporting Currency' 'DMBTR',
'Current' 'CURRENT',
'1-30 days' 'D30',
'31-60 days' 'D60',
'61-90 days' 'D90',
'91-120 days' 'D120',
'121-180 days' 'D180',
'181-240 days' 'D240',
'241-360 days' 'D360',
* '181-365 days' 'D365',
'Above 365 days' 'DA365'.
ENDFORM. "fill_fieldcat
*& Form fill_fieldcat_sum
* text
FORM fill_fieldcat_sum.
PERFORM fill_fields USING: 'Vendor Number' 'LIFNR',
'Vendor Name' 'NAME1',
'Total In Reporting Currency' 'DMBTR',
'Current' 'CURRENT',
'1-30 days' 'D30',
'31-60 days' 'D60',
'61-90 days' 'D90',
'91-120 days' 'D120',
'121-180 days' 'D180',
'181-240 days' 'D240',
'241-360 days' 'D360',
'Above 365 days' 'DA365'.
ENDFORM. "fill_fieldcat_sum
*& Form fill_fields
* text
* -->&01 text
* -->&02 text
FORM fill_fields USING &01 &02 .
wa_fieldcat-tabname = 'T_OUTPUT'. "t_output_provgr
wa_fieldcat-fieldname = &02.
wa_fieldcat-seltext_m = &01.
* wa_fieldcat-ref_fieldname = fieldname.
* wa_fieldcat-ref_tabname = 'SFLIGHT'.
* w_fieldcat-do_sum = &03.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. "fill_fields
*& Form f_layout_init
* Set the layout
FORM f_layout_init.
* P_layout-min_linesize = 170.
* p_layout-max_linesize = 170.
* P_layout-no_colhead = abap_true.
* p_layout-detail_popup = abap_true.
i_layout-colwidth_optimize = abap_true.
i_layout-zebra = abap_true.
* i_layout-subtotals_text = 'SubTotal'.
* i_layout-totals_text = 'Total'.
ENDFORM. " f_layout_init
*& Form f_eventtab_build
* Set the events
FORM f_eventtab_build.
DATA: ls_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = i_events.
READ TABLE i_events WITH KEY name = slis_ev_top_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE v_top TO: ls_event-form,
ls_event-name.
APPEND ls_event TO i_events.
ENDIF.
READ TABLE i_events WITH KEY name = slis_ev_end_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE v_eop TO: ls_event-form,
ls_event-name.
APPEND ls_event TO i_events.
ENDIF.
READ TABLE i_events WITH KEY name = slis_ev_end_of_list
INTO ls_event.
IF sy-subrc = 0.
MOVE v_eol TO: ls_event-form,
ls_event-name.
APPEND ls_event TO i_events.
ENDIF.
READ TABLE i_events WITH KEY name = slis_ev_top_of_list
INTO ls_event.
IF sy-subrc = 0.
MOVE v_tol TO: ls_event-form,
ls_event-name.
APPEND ls_event TO i_events.
ENDIF.
ENDFORM. " f_eventtab_build
*& Form f_print_control
* Set the print control
FORM f_print_control .
* i_print-no_print_listinfos = abap_true.
* i_print-no_print_selinfos = abap_true.
* i_print-reserve_lines = 2.
* i_print-no_change_print_params = abap_true.
ENDFORM. " f_print_control
*& Form f_build_header_list
* Build the header list (top of page)
FORM f_build_header_list .
lv_header = 'Vendor Open Item Analysis By Balance Of Overdue Items'(h01).
lv_text = 'Company Name:'(s01).
lv_text1 = 'Open Item As Key Date:'(s02).
lv_text2 = 'Company Code:'(s03).
lv_text3 = 'Vendor Number:'(s04).
lv_text4 = 'Vendor Name:'(s05).
* Header
CLEAR lwa_list_top.
lwa_list_top-typ = 'H'.
lwa_list_top-info = lv_header.
APPEND lwa_list_top TO i_list_top.
* Run date Display
lwa_list_top-typ = 'S'. " Item
WRITE: sy-datum TO lv_date MM/DD/YYYY.
lwa_list_top-key = 'Date :'(025).
lwa_list_top-info = lv_date.
APPEND lwa_list_top TO i_list_top.
CLEAR: lwa_list_top,
lv_date.
* Run time Display
lwa_list_top-typ = 'S'. " Item
WRITE: sy-uzeit TO lv_time USING EDIT MASK '__:__:__'.
lwa_list_top-key = 'Time :'(026).
lwa_list_top-info = lv_time.
APPEND lwa_list_top TO i_list_top.
CLEAR: lwa_list_top,
lv_time.
CLEAR lwa_list_top.
* Company Name
lwa_list_top-typ = 'S'.
lwa_list_top-key = lv_text.
lwa_list_top-info = lv_butxt.
APPEND lwa_list_top TO i_list_top.
CLEAR lwa_list_top.
*Open Item As Key Date
lwa_list_top-typ = 'S'.
lwa_list_top-key = lv_text1.
lwa_list_top-info = p_bldat.
APPEND lwa_list_top TO i_list_top.
CLEAR lwa_list_top.
* Company Code
lwa_list_top-typ = 'S'.
lwa_list_top-key = lv_text2.
lwa_list_top-info = s_bukrs-low.
APPEND lwa_list_top TO i_list_top.
CLEAR lwa_list_top.
** Vendor Number
* lwa_list_top-typ = 'S'.
* lwa_list_top-key = lv_text3.
* lwa_list_top-info = lv_butxt2.
* APPEND lwa_list_top TO i_list_top.
* CLEAR lwa_list_top.
**Vendor Name
* lwa_list_top-typ = 'S'.
* lwa_list_top-key = lv_text4.
* lwa_list_top-info = lv_butxt1.
* APPEND lwa_list_top TO i_list_top.
ENDFORM. " f_build_header_list
*& Form f_build_header_list1
* text
* --> p1 text
* <-- p2 text
FORM f_build_header_list1 .
lv_header = 'Vendor Open Item Analysis By Balance Of Overdue Items'(h01).
lv_text = 'Company Name:'(s01).
lv_text1 = 'Open Item As Key Date:'(s02).
lv_text2 = 'Company Code:'(s03).
lv_text3 = 'Vendor Number:'(s04).
lv_text4 = 'Vendor Name:'(s05).
lwa_list_top-typ = 'H'.
lwa_list_top-info = lv_header.
APPEND lwa_list_top TO i_list_top.
* Run date Display
lwa_list_top-typ = 'S'. " Item
WRITE: sy-datum TO lv_date MM/DD/YYYY.
lwa_list_top-key = 'Date :'(025).
lwa_list_top-info = lv_date.
APPEND lwa_list_top TO i_list_top.
CLEAR: lwa_list_top,
lv_date.
* Run time Display
lwa_list_top-typ = 'S'. " Item
WRITE: sy-uzeit TO lv_time USING EDIT MASK '__:__:__'.
lwa_list_top-key = 'Time :'(026).
lwa_list_top-info = lv_time.
APPEND lwa_list_top TO i_list_top.
CLEAR: lwa_list_top,
lv_time.
CLEAR lwa_list_top.
* Company Name
lwa_list_top-typ = 'S'.
lwa_list_top-key = lv_text.
lwa_list_top-info = lv_butxt.
APPEND lwa_list_top TO i_list_top.
CLEAR lwa_list_top.
*Open Item As Key Date
lwa_list_top-typ = 'S'.
lwa_list_top-key = lv_text1.
lwa_list_top-info = p_bldat.
APPEND lwa_list_top TO i_list_top.
CLEAR lwa_list_top.
ENDFORM. " f_build_header_list1
*& Form f_build_sort
* Set the sorting sequence
FORM f_build_sort .
DATA: l_sort TYPE slis_sortinfo_alv.
l_sort-spos = '1'.
l_sort-fieldname = 'LIFNR'.
l_sort-up = abap_true.
l_sort-group = '*'.
* l_sort-subtot = 'X'.
APPEND l_sort TO i_sort.
* l_sort-spos = '2'.
* l_sort-fieldname = 'NAME1'.
* l_sort-up = abap_true.
* l_sort-group = '*'.
** l_sort-subtot = 'X'.
* APPEND l_sort TO i_sort.
* l_sort-spos = '2'.
* l_sort-fieldname = 'LIFNR'.
* l_sort-up = abap_true.
* l_sort-subtot = abap_true.
* APPEND l_sort TO i_sort.
* l_sort-spos = '1'.
* l_sort-fieldname = 'VBELN'.
* l_sort-up = abap_true.
* l_sort-subtot = abap_true.
* APPEND l_sort TO i_sort.
* l_sort-spos = '2'.
* l_sort-fieldname = 'POSNR'.
* l_sort-up = abap_true.
* l_sort-subtot = abap_true.
* APPEND l_sort TO i_sort.
ENDFORM. " f_build_sort
*& Form f_list_display
* Display the ALV list report
* -->PT_DATA Internal table containing the data
FORM f_list_display TABLES pt_data.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = i_variant-report
is_layout = i_layout
it_fieldcat = i_fieldcat[]
it_sort = i_sort
i_default = 'X'
i_save = 'A'
is_variant = i_variant
it_events = i_events[]
is_print = i_print
TABLES
t_outtab = pt_data.
ENDFORM. "f_list_display
*& Form TOP_OF_PAGE
* TOP_OF_PAGE Event
FORM top_of_page. "#EC CALLED
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
* i_logo = 'ZLOGO_BAB'
it_list_commentary = i_list_top
i_alv_form = 'X'.
* PERFORM f_print_header USING SPACE SPACE SPACE.
ENDFORM. "TOP_OF_PAGE
*& Form END_OF_PAGE
* END_OF_PAGE Event
FORM end_of_page. "#EC CALLED
* DATA: l_pos(3) TYPE n VALUE 0,
* l_foot(30) VALUE '*** END OF PAGE ***'.
* l_pos = ( sy-linsz / 2 ) - ( STRLEN( l_foot ) / 2 ).
* ULINE.
* WRITE: /, AT l_pos l_foot.
ENDFORM. "END_OF_PAGE
*& Form END_OF_LIST
* END_OF_LIST Event
FORM end_of_list. "#EC CALLED
* DATA: l_pos(3) TYPE n VALUE 0,
* l_foot(30) VALUE '*** END OF REPORT ***'.
* l_pos = ( sy-linsz / 2 ) - ( STRLEN( l_foot ) / 2 ).
* ULINE.
* WRITE: /, AT l_pos l_foot.
ENDFORM. "END_OF_LIST
*& Form f_print_header
* Print the header (Top-Of-Page)
* -->P_P_TITLE1 Title text 1
* -->P_P_TITLE2 Title text 2
* -->P_P_TITLE3 Title text 3
FORM f_print_header USING p_title1 LIKE sy-title
p_title2 LIKE sy-title
p_title3 LIKE sy-title.
DATA: l_post1 TYPE i,
l_post2 TYPE i,
l_post3 TYPE i,
l_posin TYPE i.
l_post1 = ( sy-linsz / 2 ) - ( STRLEN( p_title1 ) / 2 ).
l_post2 = ( sy-linsz / 2 ) - ( STRLEN( p_title2 ) / 2 ).
l_post3 = ( sy-linsz / 2 ) - ( STRLEN( p_title3 ) / 2 ).
l_posin = sy-linsz - 17.
WRITE: / 'Report :', sy-cprog.
WRITE AT l_post1 p_title1.
WRITE AT l_posin 'Date :'.
WRITE sy-datum.
WRITE: / 'Cli/Sys :', sy-mandt, '/', sy-sysid.
WRITE AT l_post2 p_title2.
WRITE AT: l_posin 'Time :'.
WRITE sy-uzeit.
WRITE: / 'UserID :', sy-uname.
WRITE AT l_post3 p_title3.
WRITE AT l_posin 'Page :'.
WRITE sy-pagno NO-ZERO.
ENDFORM. " f_print_header
*& Form f_build_sort1
* text
* --> p1 text
* <-- p2 text
form f_build_sort1 .
DATA: l_sort TYPE slis_sortinfo_alv.
l_sort-spos = '1'.
l_sort-fieldname = 'LIFNR'.
l_sort-up = abap_true.
l_sort-group = '*'.
* l_sort-subtot = 'X'.
APPEND l_sort TO i_sort.
l_sort-spos = '2'.
l_sort-fieldname = 'NAME1'.
l_sort-up = abap_true.
l_sort-group = '*'.
* l_sort-subtot = 'X'.
APPEND l_sort TO i_sort.
* l_sort-spos = '3'.
* l_sort-fieldname = 'DMBTR'.
* l_sort-up = abap_true.
* l_sort-group = '*'.
* l_sort-subtot = 'X'.
* APPEND l_sort TO i_sort.
endform. " f_build_sort1
Regards
Sunita.Hey,
U can try out "SORTING THE VENDORS AND DO THE SUM in the NETWR"... try it out....see u sort the customers...rit?...keep it as usual and little mentoned above...
hope dis help u out...
Thanks. -
A type table as a row in a table
The question is simple. Can I use a type table into a Z table ?? Any way to do this ??
Thanks in advance.hi maraia,
Structures
A structure is a sequence of any other data types from the ABAP Dictionary, that is, data elements, structures, table types, or database tables. When you create a structure in the ABAP Dictionary, each component must have a name and a data type.
In an ABAP program, you can use the TYPEaddition to refer directly to a structure.
If you define a local data type in a program by referring to a structure as follows:
TYPES dtype TYPE structure.
the construction blueprint of the structure is used to create a local structure dtype in the program. The predefined Dictionary data types of the domains used by the data elements in the structure are converted into the corresponding ABAP types. The semantic attributes of the data elements are used for the corresponding components of the structure in the program. The components of the local structure dtype have the same names as those of the structure in the ABAP Dictionary.
To ensure compatibility with previous releases, it is still possible to use the LIKE addition in an ABAP program to refer to a structure in the ABAP Dictionary (except in classes).
Suppose the structure STRUCT is defined as follows in the ABAP Dictionary:
Field name
Type name
Short Description
COL1
CHAR01
Character field with length 1
COL2
CHAR08
Character field with length 8
COL3
CHAR10
Character field with length 10
The types CHAR01 to CHAR10 are data elements with corresponding domains. We can refer to this structure in ABAP:
TYPES struct_type TYPE struct.
DATA wa TYPE struct_type.
wa-col1 = '1'.
wa-col2 = '12345678'.
wa-col3 = '1234567890'.
This program creates a local structure in the program - struct_type - and a corresponding data object wa. We can address the components using the component names from the original structure.
Table types
Table types are construction blueprints for internal tables that are stored in the ABAP Dictionary. When you create a table type in the ABAP Dictionary, you specify the line type, access type, and key. The line type can be any data type from the ABAP Dictionary, that is, a data element, a structure, a table type, or the type of a database table. You can also enter a predefined Dictionary type directly as the line type, in the same way that you can with a domain.
In an ABAP program, you can use the TYPEaddition to refer directly to a table type.
If you define a local data type in a program by referring to a table type as follows:
TYPES dtype TYPE table.
the construction blueprint of the table type is used to create a local internal table dtype in the program. The predefined Dictionary data types of the domains used by the data elements in the structure are converted into the corresponding ABAP types. The semantic attributes of the data elements are used for the corresponding components of the internal table in the program.
Suppose the table type STRUCT_TABLE is defined in the Dictionary with the line type STRUCT from the previous example. We can refer to this in ABAP:
TYPES table_type TYPE struct_table.
DATA: table_wa TYPE table_type,
line_wa LIKE LINE OF table_wa.
LOOP AT table_wa INTO line_wa.
WRITE: line_wa-col1, line_wa-col1, line_wa-col1.
ENDLOOP.
This program defines an internal table type table_type . From it, we define data objects table_wa and, consequently, line_wa. line_wa corresponds to the line type of the table type in the Dictionary, and is therefore compatible with the structure STRUCT
Type Groups
Before Release 4.5A, it was not possible to define standalone types in the ABAP Dictionary to which you could refer using a TYPEaddition in an ABAP program. It was only possible to refer to flat structures. Structures in programs corresponded to the structures of database tables or structures in the ABAP Dictionary. In ABAP programs, you could only refer to database tables and structures in the ABAP Dictionary using LIKE. It was, however, possible to refer to individual components of the Dictionary type. Complex local data types such as internal tables or deep structures had no equivalent in the ABAP Dictionary. The solution to this from Release 3.0 onwards was to use type groups. Type groups were based on the include technique, and allowed you to store any type definitions globally in the Dictionary by defining them using TYPES statements.
The definition of a type group is a fragment of ABAP code which you enter in the ABAP Editor. The first statement for the type group pool is always:
TYPE-POOL pool.
After that, you define data types using the statement TYPES. It was also possible to define global constants using the CONSTANTS statement. All the names of these data types and constants must begin with the name of the type group and an underscore: pool_
In an ABAP program, you must declare a type group as follows before you can use it:
TYPE-POOLS pool.
if you want complete info just click
http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3138358411d1829f0000e829fbfe/content.htm
thanks
karthik
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Apr 15, 2008 3:09 PM -
Error in opening of Pdf file attachment
hi,
i am sending pdf file as an attachment to mail recipient, after receiving that pdf attachment when the user tries to open that attachment he is getting the following error message.
*"Adobe reader could not open file because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email and wasn't correctly decoded"*
Please give me any suggestions to over come this error.
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Feb 15, 2008 3:13 PMHi
can you compare your code with attached code , and do required changes if any thing needed
FORM sub_generate_tr_report .
* Internal table declarations
DATA lit_mseg TYPE STANDARD TABLE OF mseg INITIAL SIZE 0.
DATA lit_temp TYPE STANDARD TABLE OF gty_gr_creat INITIAL SIZE 0.
DATA lit_otf TYPE itcoo OCCURS 0 WITH HEADER LINE.
DATA lit_tline TYPE TABLE OF tline WITH HEADER LINE.
DATA lit_objtxt TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0.
DATA lit_objpack TYPE STANDARD TABLE OF sopcklsti1 INITIAL SIZE 0.
DATA lit_objbin TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0.
DATA lit_receiver TYPE STANDARD TABLE OF somlreci1 INITIAL SIZE 0.
* Workarea declarations
DATA lwa_ctrlop TYPE ssfctrlop .
DATA lwa_compop TYPE ssfcompop .
DATA lwa_return TYPE ssfcrescl .
DATA lwa_tline TYPE tline .
DATA lwa_objtxt TYPE solisti1 .
DATA lwa_objpack TYPE sopcklsti1.
DATA lwa_doc_data TYPE sodocchgi1.
DATA lwa_objbin TYPE solisti1 .
DATA lwa_receiver TYPE somlreci1 .
DATA lwa_temp TYPE gty_gr_creat.
* Variable declarations
DATA lv_form_name TYPE tdsfname VALUE 'ZZ_PTS446_MASTER_TR_REPORT'.
DATA lv_dlist TYPE so_obj_nam VALUE 'ZPTS446'.
DATA lv_func_mod TYPE rs38l_fnam .
DATA lv_len_in LIKE sood-objlen.
DATA lv_time TYPE syuzeit .
DATA lv_time2 TYPE char8 .
DATA lv_date2 TYPE char10 .
DATA lv_info TYPE so_text255 .
DATA lv_lines TYPE i .
DATA lv_buffer TYPE string .
* Constants declarations
CONSTANTS lc_x TYPE char1 VALUE 'X' .
CONSTANTS lc_c TYPE so_escape VALUE 'C' .
CONSTANTS lc_locl TYPE rspopname VALUE 'LOCL' .
CONSTANTS lc_printer TYPE tddevice VALUE 'PRINTER'.
CONSTANTS lc_raw TYPE so_obj_tp VALUE 'RAW' .
CONSTANTS lc_pdf TYPE so_obj_tp VALUE 'PDF' .
CONSTANTS lc_colon TYPE char1 VALUE ':' .
CONSTANTS lc_slash TYPE char1 VALUE '/' .
CONSTANTS lc_int TYPE char3 VALUE 'INT' .
* Moving record from GIT_GR_CREAT to GIT_TEMP internal table
lit_temp[] = git_gr_creat[].
* Delete record from internal table GIT_TEMP, where STAT is not initial
* DELETE lit_temp WHERE NOT stat IS INITIAL.
DELETE lit_temp WHERE stat EQ 'X'.
DELETE lit_temp WHERE stat EQ 'Q'.
* CLEAR lwa_temp.
* LOOP AT lit_temp INTO lwa_temp.
* IF lwa_temp-stat EQ 'X'
* OR lwa_temp-stat EQ 'Q'.
* DELETE lit_temp FROM lwa_temp.
* ENDIF.
* ENDLOOP.
IF NOT lit_temp[] IS INITIAL.
*-- Select data from MSEG table
SELECT matnr "Material Number
erfmg "Quantity in unit of entry
tbnum "Transfer Requirement Number
INTO CORRESPONDING FIELDS OF TABLE lit_mseg
FROM mseg "Document Segment: Material
FOR ALL ENTRIES IN lit_temp
WHERE mblnr = lit_temp-mblnr
AND mjahr = lit_temp-gjahr.
*-- If select successful
IF sy-subrc EQ 0.
*---- Get name of the function module for smartform 'ZZ_PTS446_MASTER_TR_REPORT'
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = lv_form_name
IMPORTING
fm_name = lv_func_mod
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
*---- Check function module name is not initial.
IF NOT lv_func_mod IS INITIAL.
*------ Select default printer based on User settings
SELECT SINGLE spld
FROM usr01
INTO usr01-spld
WHERE bname = sy-uname.
IF sy-subrc IS INITIAL.
lwa_compop-tddest = usr01-spld. "Device type
ELSE.
lwa_compop-tddest = lc_locl. "Device type
ENDIF.
lwa_compop-tdnoprev = lc_x. "No print preview
lwa_compop-tdnoprint = lc_x. "No printing from print preview
lwa_compop-tdiexit = lc_x.
*------ Setting control parameters
lwa_ctrlop-getotf = lc_x.
lwa_ctrlop-no_dialog = lc_x.
lwa_ctrlop-device = lc_printer.
*------ Call smartform function module
CALL FUNCTION lv_func_mod
EXPORTING
control_parameters = lwa_ctrlop
output_options = lwa_compop
IMPORTING
job_output_info = lwa_return
TABLES
it_mseg = lit_mseg
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
*------ If smartform function module successful
IF sy-subrc EQ 0.
*-------- Transfer OTF data to internal table LIT_OTF
lit_otf[] = lwa_return-otfdata[].
*-------- Convert to PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = lv_len_in
TABLES
otf = lit_otf
lines = lit_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
*-------- If above function module is successful
IF sy-subrc EQ 0.
*---------- Mail body
CLEAR lwa_objtxt.
CONCATENATE 'TR Report of RF Inbound Deliveries'(001)
'is attached.'(002)
INTO lwa_objtxt SEPARATED BY space.
APPEND lwa_objtxt TO lit_objtxt.
*---------- Append Date and Time into Body of email.
CLEAR lwa_objtxt.
MOVE 'File is generated on'(003) TO lv_info.
lv_time = sy-uzeit.
CONCATENATE lv_time+0(2)
lv_time+2(2)
lv_time+4(2)
INTO
lv_time2 SEPARATED BY lc_colon.
CONCATENATE sy-datum+4(2)
sy-datum+6(2)
sy-datum+0(4)
INTO lv_date2 SEPARATED BY lc_slash.
CONCATENATE lv_info
lv_date2
'At'(004)
lv_time2
INTO lv_info
SEPARATED BY space.
lwa_objtxt = lv_info.
APPEND lwa_objtxt TO lit_objtxt.
*---------- Document size
CLEAR: lv_lines, lwa_objtxt.
DESCRIBE TABLE lit_objtxt LINES lv_lines.
READ TABLE lit_objtxt INTO lwa_objtxt INDEX lv_lines.
*---------- Populate packing list for body text
CLEAR lwa_objpack.
lwa_objpack-head_start = 1.
lwa_objpack-head_num = 0.
lwa_objpack-body_start = 1.
lwa_objpack-body_num = lv_lines.
lwa_objpack-doc_type = lc_raw.
APPEND lwa_objpack TO lit_objpack.
CLEAR lwa_objpack.
*---------- Mail subject line
CLEAR lwa_doc_data.
lwa_doc_data-obj_name = 'TR REPORT'(005).
lwa_doc_data-obj_descr = 'TR Report of RF Inbound Deliveries'(001).
lwa_doc_data-doc_size = ( lv_lines - 1 ) * 255 + STRLEN( lwa_objtxt ).
*---------- Populating internal table LIT_OBJBIN
LOOP AT lit_tline INTO lwa_tline.
TRANSLATE lwa_tline USING ' ~'.
CONCATENATE lv_buffer lwa_tline INTO lv_buffer.
ENDLOOP.
TRANSLATE lv_buffer USING '~ '.
DO.
APPEND lv_buffer TO lit_objbin.
SHIFT lv_buffer LEFT BY 255 PLACES.
IF lv_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
*---------- Get total no.of lines of Object table(attachment)
CLEAR lv_lines.
DESCRIBE TABLE lit_objbin LINES lv_lines.
*---------- Packing list for attachment
lwa_objpack-transf_bin = lc_x .
lwa_objpack-head_start = 1 .
lwa_objpack-head_num = 1 .
lwa_objpack-body_start = 1 .
lwa_objpack-body_num = lv_lines.
lwa_objpack-doc_type = lc_pdf .
lwa_objpack-obj_name = 'TR REPORT'(005).
lwa_objpack-obj_descr = 'TR_REPORT'(006).
lwa_objpack-doc_size = lv_lines * 255.
APPEND lwa_objpack TO lit_objpack.
CLEAR lwa_objpack.
*---------- Giving the receiver email-id
CLEAR lwa_receiver.
lwa_receiver-receiver = lv_dlist.
lwa_receiver-rec_type = lc_c.
APPEND lwa_receiver TO lit_receiver.
*---------- Calling the function module to sending email
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = lwa_doc_data
put_in_outbox = lc_x
commit_work = lc_x
TABLES
packing_list = lit_objpack
contents_bin = lit_objbin
contents_txt = lit_objtxt
receivers = lit_receiver
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
IF sy-subrc EQ 0.
*------------ Wait upto 2 secounds
WAIT UP TO 2 SECONDS.
*------------ Call the RSCONN01 (SAPconnect: Start Send Process)
SUBMIT rsconn01 WITH mode = lc_int
* WITH output = 'X'
AND RETURN.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
REFRESH: lit_mseg , lit_temp , lit_otf , lit_tline ,
lit_objtxt , lit_objpack, lit_objbin , lit_receiver.
CLEAR: lwa_ctrlop , lwa_compop , lwa_return , lwa_tline ,
lwa_objtxt , lwa_objpack, lwa_doc_data, lwa_objbin ,
lwa_receiver.
CLEAR: lv_func_mod , lv_len_in , lv_time , lv_time2 ,
lv_date2 , lv_info , lv_lines , lv_buffer .
Code Formatted by: Alvaro Tejada Galindo on Feb 15, 2008 3:13 PM -
User Eixts / BADI for the cutomer master IDOC (DEBMAS06)
Hi All,
We have requirement to extend the customer master IDOC 'DEBMAS06' to add the address fields i.e (ADRC-STR_SUPPL3,STR_SUPPL4,STR_SUPPL5). Can any one tell me the suitable EXITs or BADI's to populate street3, street4 and stree5 to the customer master. Otherwise can any one tell me how to over come this problem.
Thanks in advance
K N CHi Naveena,
Create a segment with the fields you have hased for and thenextend it and write the code
Create the project in the enhancement" VSV00001 User exit Customer and vendor distribution Receipt/issue
Crearte the code as follows in the function exit( EXIT_SAPLVV01_001) under tthe include as follows:
I have create a zcustomer as the segment so wrote the code according to that.
DATA: WA_ZCUSTOMER TYPE ZCUSTOMER.
DATA: LS_DATA TYPE EDIDD,
LS_E1KNA1M TYPE EDIDD,
LS_SEGMENT TYPE ZCUSTOMER,
LV_COUNT TYPE I.
DATA: L_KUNNR TYPE CHAR10.
DATA: L_ADRNR TYPE KNA1-ADRNR.
CHECK MESSAGE_TYPE = 'DEBMAS'.
CHECK IDOC_TYPE = 'DEBMAS06'.
*IDOC_CIMTYPE = 'ZCUSTOMER'.
READ TABLE IDOC_DATA INTO LS_DATA WITH KEY SEGNAM = 'E1KNA11'.
IF SY-SUBRC = 0.
LOOP AT IDOC_DATA INTO LS_DATA FROM SY-TABIX.
IF LS_DATA-SEGNAM NE 'E1KNA11'.
EXIT.
ELSE.
LV_COUNT = SY-TABIX + 1. "Get the segment position as per IDoc Defn.
READ TABLE IDOC_DATA INTO LS_DATA WITH KEY SEGNAM = 'ZCUSTOMER'.
IF SY-SUBRC NE 0.
READ TABLE IDOC_DATA INTO LS_E1KNA1M WITH KEY SEGNAM = 'E1KNA1M'.
IF SY-SUBRC = 0.
L_KUNNR = LS_E1KNA1M-SDATA+3(10). "Customer No.
SELECT SINGLE ADRNR FROM KNA1 INTO L_ADRNR "Address no.
WHERE KUNNR = L_KUNNR.
IF SY-SUBRC = 0.
SELECT SINGLE STR_SUPPL3 LOCATION CITY2 FROM ADRC INTO WA_ZCUSTOMER
WHERE ADDRNUMBER = L_ADRNR. "Required fields
IF SY-SUBRC = 0.
LS_SEGMENT-STR_SUPPL3 = WA_ZCUSTOMER-STR_SUPPL3.
LS_SEGMENT-STR_SUPPL4 = WA_ZCUSTOMER-STR_SUPPL4.
LS_SEGMENT-STR_SUPPL5 = WA_ZCUSTOMER-STR_SUPPL5.
ENDIF.
ENDIF.
ENDIF.
Edited by: Farhy Farhy on Sep 24, 2010 12:19 PM -
Mass validations in selection screen
Hello experts,
I have a simple requirement to check "if atleast one of the fields on selection screen is filled or not".
If all the fields are initial, i'll raise a message.
I dont want to check all the fields one by one using ANDs.
The closest I got was-
loop at screen.
field = screen-name.
see if the field is empty.
if yes, increment the counter.
endif.
check if the counter is still zero. That means all fields are empty. Raise message.
The problem here is, in "screen-name", i'll get the name of screen field. How do I read it? How to find the value in a varible that is stored in another variable? I tried paranthesis ( screen-field ) = value. But it doesnt work. If that can be done, my problem's solved.
Thanks in advance!
Sumit Nene.This should be a good start, if you still persist to move ahead with your initial approach inspite of Thomas's suggestion.
TABLES:
mara.
SELECT-OPTIONS:
s_matnr FOR mara-matnr.
PARAMETERS:
p_test1 TYPE char10,
p_test2 TYPE char10.
DATA:
count TYPE i.
FIELD-SYMBOLS:
<fs> TYPE ANY.
AT SELECTION-SCREEN.
IF sy-ucomm = 'ONLI'.
CLEAR count.
LOOP AT SCREEN.
CHECK: screen-input = 1,
screen-active = 1.
ASSIGN (screen-name) TO <fs>.
IF <fs> IS ASSIGNED AND
<fs> IS NOT INITIAL.
ADD 1 TO count.
UNASSIGN <fs>.
ENDIF.
ENDLOOP.
ENDIF.
-Rajesh
Edit
P.S : I haven't tested the above solution thoroughly, if for any reasons you find issues with the above approach, as an alternative you can consider using the FM 'RS_REFRESH_FROM_SELECTOPTIONS' to read the selection screen contents. But as already suggested, it would be easy to query the fields individually, you don't want to perform a simple validation with a complicated processing...
Edited by: Rajesh Paruchuru on Jul 12, 2011 10:03 AM -
Hi all,
My problem is, i have calculated time in minutes i have to show output in terms of minute range. The minute range is defined in the selection screen by the user.
Eg If user has defined in selection screen the minute range as 10.
Now if the calculated minutes i have is 5 min then output = show range as 0-10
if i have 13 min then output = shoe range as 10-20 and so on.
Similarly if User enters 5 in selection screen, then
3 min output = show range as 0-5
13 min ouput = show range as 10-15 and so on.
Is there any FM which could help me, or nay other possible way.
Please help me out. Points will be rewarded.
Thanks
VijayHi vijay,
no idea if there is a standard function but such a function module is written quite fast. Here an example. You have to adapt the data types perhaps if you have greater value ranges.
FUNCTION zrwe_range.
""Local Interface:
*" IMPORTING
*" REFERENCE(IV_VALUE) TYPE I
*" REFERENCE(IV_RANGE) TYPE I
*" EXPORTING
*" REFERENCE(EV_RANGE) TYPE CHAR10
local data definition
DATA:
lv_segment TYPE i,
lv_start TYPE i,
lv_end TYPE i,
lv_char_buff1 TYPE char4,
lv_char_buff2 TYPE char4,
lv_range TYPE char10.
clear the exporting parameter
CLEAR:
ev_range.
get the segment the value is in
lv_segment = ( iv_value DIV iv_range ) + 1.
get the start
lv_start = ( lv_segment - 1 ) * iv_range.
get the end
lv_end = ( lv_segment ) * iv_range.
build the result
WRITE lv_start TO lv_char_buff1.
WRITE lv_end TO lv_char_buff2.
CONDENSE lv_char_buff1.
CONDENSE lv_char_buff2.
CONCATENATE
lv_char_buff1
lv_char_buff2
INTO
ev_range.
ENDFUNCTION.
To sum up several entries just call such a function module in a loop and collect them into a table.
Best regards
Roman Weise -
hi
please send me one example of follwing reports
1.alv
2.interactive report
3.classicalhi,
Here ia the code for 3 type of ALV ( all interactive)
*& Report ZALV_PRDS
REPORT zalv_prds.
*--Simple ALV Grid with Header-Footer(Interactive)--
TYPE-POOLS : slis.
TABLES : mara,
makt,
marc.
DATA : BEGIN OF itab OCCURS 0,
matnr LIKE mara-matnr,
maktx LIKE makt-maktx,
werks LIKE marc-werks,
END OF itab.
DATA : t_fcat TYPE slis_t_fieldcat_alv,
t_eve TYPE slis_t_event,
st_line TYPE slis_listheader,
t_list_top_page TYPE slis_t_listheader,
t_list_end_page TYPE slis_t_listheader.
DATA : t_mat LIKE mara-matnr.
SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : mat FOR mara-matnr.
SELECTION-SCREEN : END OF BLOCK blk1.
INITIALIZATION.
PERFORM build_cat USING t_fcat.
PERFORM build_eve.
START-OF-SELECTION.
PERFORM get_data.
PERFORM build_header USING t_list_top_page[].
PERFORM build_footer USING t_list_end_page[].
PERFORM dis_data.
*& Form buils_cat
text
-->TEMP_FCAT text
FORM build_cat USING temp_fcat TYPE slis_t_fieldcat_alv.
DATA : wa_fcat TYPE slis_fieldcat_alv.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-seltext_m = 'Material'.
APPEND wa_fcat TO temp_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MAKTX'.
wa_fcat-seltext_m = 'Material Description'.
APPEND wa_fcat TO temp_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'WERKS'.
wa_fcat-seltext_m = 'Plant'.
wa_fcat-row_pos = 2.
APPEND wa_fcat TO temp_fcat.
CLEAR wa_fcat.
ENDFORM. "build_cat
*& Form build_eve
text
FORM build_eve.
DATA : wa_eve TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = t_eve
EXCEPTIONS
LIST_TYPE_WRONG = 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.
READ TABLE t_eve INTO wa_eve WITH KEY name = 'END_OF_LIST'.
IF sy-subrc = 0.
wa_eve-form = 'END_OF_PAGE'.
MODIFY t_eve FROM wa_eve INDEX sy-tabix.
ENDIF.
ENDFORM. "build_eve
*& Form get_data
text
FORM get_data.
SELECT maramatnr maktmaktx marc~werks INTO CORRESPONDING FIELDS OF TABLE itab
FROM mara INNER JOIN makt ON
maramatnr = maktmatnr
INNER JOIN marc ON
maramatnr = marcmatnr
WHERE mara~matnr IN mat.
ENDFORM. "get_data
*& Form dis_data
text
FORM dis_data.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'ZALV_PRDS'
i_callback_user_command = 'USER_COMMAND'
i_callback_top_of_page = 'TOP_OF_PAGE'
it_fieldcat = t_fcat
i_save = 'A'
it_events = t_eve
TABLES
t_outtab = itab
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.
ENDFORM. "dis_data
*& Form build_header
text
-->TEMP_LIST text
-->TTYPE text
-->SLIS_T_LISTHEADER text
FORM build_header USING temp_list TYPE slis_t_listheader.
CLEAR st_line.
st_line-typ = 'H'.
st_line-info = 'Material Info'.
APPEND st_line TO temp_list.
CLEAR st_line.
st_line-typ = 'H'.
st_line-info = '----
APPEND st_line TO temp_list.
CLEAR st_line.
st_line-typ = 'H'.
st_line-info = 'Material Info1'.
APPEND st_line TO temp_list.
ENDFORM. "build_header
*& Form build_footer
text
-->TEMP_LIST text
FORM build_footer USING temp_list TYPE slis_t_listheader.
CLEAR st_line.
st_line-typ = 'H'.
st_line-info = 'Dhwani Shah'.
APPEND st_line TO temp_list.
ENDFORM. "build_header
*& Form top_Of_page
text
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_list_top_page.
ENDFORM. "top_Of_page
*& Form end_of_page
text
FORM end_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_list_end_page.
ENDFORM. "end_of_page
*& Form user_command
text
FORM user_command USING u_com LIKE sy-ucomm sel_field TYPE slis_selfield.
CASE u_com.
WHEN '&IC1'.
IF sel_field-fieldname = 'MATNR'.
READ TABLE itab INDEX sel_field-tabindex.
IF sy-subrc = 0.
t_mat = itab-matnr.
SET PARAMETER ID 'MAT' FIELD t_mat.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
ENDIF.
ENDIF.
ENDCASE.
ENDFORM. "user_command
--Hierarchical ALV(Interactive)--
TYPE-POOLS : slis.
TABLES : mseg.
DATA : BEGIN OF itab_head OCCURS 0,
mat LIKE mseg-matnr,
matnr LIKE mseg-matnr,
werks LIKE mseg-werks,
END OF itab_head.
DATA : BEGIN OF itab_item OCCURS 0,
mat LIKE mseg-matnr,
matnr LIKE mseg-matnr,
werks LIKE mseg-werks,
mblnr LIKE mseg-mblnr,
menge LIKE mseg-menge,
END OF itab_item.
DATA : t_fcat TYPE slis_t_fieldcat_alv,
key_info TYPE slis_keyinfo_alv,
t_eve TYPE slis_t_event,
gt_subtot TYPE slis_t_sortinfo_alv,
subtot LIKE LINE OF gt_subtot,
t_listhead TYPE slis_t_listheader,
st_line TYPE slis_listheader.
DATA : lin_no TYPE i.
DATA : t_mtdoc LIKE mseg-mblnr.
SELECT-OPTIONS : mat FOR mseg-matnr.
INITIALIZATION.
PERFORM build_cat USING t_fcat.
PERFORM build_eve.
START-OF-SELECTION.
PERFORM get_data.
PERFORM dis_data.
*& Form build_cat
text
-->TEMP_FCAT text
FORM build_cat USING temp_fcat TYPE slis_t_fieldcat_alv.
DATA : wa_fcat TYPE slis_fieldcat_alv.
wa_fcat-tabname = 'ITAB_HEAD'.
wa_fcat-fieldname = 'MAT'.
wa_fcat-seltext_m = 'Material'.
APPEND wa_fcat TO temp_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_HEAD'.
wa_fcat-fieldname = 'WERKS'.
wa_fcat-seltext_m = 'Plant'.
APPEND wa_fcat TO temp_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_ITEM'.
wa_fcat-fieldname = 'MBLNR'.
wa_fcat-seltext_m = 'Material Doc.'.
APPEND wa_fcat TO temp_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_ITEM'.
wa_fcat-fieldname = 'MENGE'.
wa_fcat-seltext_m = 'Quantity'.
wa_fcat-edit = 'X'.
wa_fcat-input = 'X'.
wa_fcat-do_sum = 'Y'.
APPEND wa_fcat TO temp_fcat.
CLEAR wa_fcat.
subtot-spos = 1.
subtot-fieldname = 'MAT'.
subtot-tabname = 'ITAB_HEAD'.
subtot-up = 'X'.
subtot-group = 'X'.
subtot-subtot = 'X'.
subtot-expa = 'X'.
APPEND subtot TO gt_subtot.
ENDFORM. "build_cat
*& Form build_eve
text
FORM build_eve.
DATA : wa_eve TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = t_eve
EXCEPTIONS
LIST_TYPE_WRONG = 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.
READ TABLE t_eve INTO wa_eve WITH KEY name = 'TOP_OF_PAGE'.
IF sy-subrc = 0.
wa_eve-form = 'TOP_OF_PAGE'.
MODIFY t_eve FROM wa_eve INDEX sy-tabix.
ENDIF.
ENDFORM. "build_eve
*& Form get_data
text
FORM get_data.
SELECT matnr werks mblnr menge FROM mseg INTO CORRESPONDING FIELDS OF TABLE itab_item
WHERE matnr IN mat.
ENDFORM. "get_data
*& Form dis_data
text
FORM dis_data.
key_info-header01 = 'MAT'.
key_info-item01 = 'MATNR'.
key_info-header02 = 'WERKS'.
key_info-item02 = 'WERKS'.
REFRESH itab_head.
LOOP AT itab_item.
ON CHANGE OF itab_item-matnr OR itab_item-werks.
MOVE-CORRESPONDING itab_item TO itab_head.
itab_head-mat = itab_item-matnr.
APPEND itab_head.
ENDON.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
i_callback_program = 'ZALV_PRDS'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = t_fcat
it_sort = gt_subtot
it_events = t_eve[]
i_tabname_header = 'ITAB_HEAD'
i_tabname_item = 'ITAB_ITEM'
is_keyinfo = key_info
TABLES
t_outtab_header = itab_head
t_outtab_item = itab_item
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.
ENDFORM. "dis_data
*& Form user_Command
text
-->U_COMM text
-->SELFIELD text
FORM user_command USING u_comm TYPE sy-ucomm selfield TYPE slis_selfield.
CASE u_comm.
WHEN '&IC1'.
IF selfield-fieldname = 'MENGE'.
GET CURSOR LINE lin_no.
ELSE.
READ TABLE itab_item INDEX selfield-tabindex.
t_mtdoc = itab_item-mblnr.
SET PARAMETER ID 'MBN' FIELD t_mtdoc.
CALL TRANSACTION 'MIGO' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM. "user_Command
*& Form top_of_page
text
FORM top_of_page.
CLEAR st_line.
st_line-typ = 'H'.
st_line-info = 'Dhwani Shah'.
APPEND st_line TO t_listhead.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_listhead
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
ENDFORM. "top_of_page
--Block ALV(Interactive)--
TYPE-POOLS : slis.
TABLES : mara,
makt.
SELECT-OPTIONS : mat FOR mara-matnr.
DATA : BEGIN OF itab OCCURS 0,
matnr LIKE mara-matnr,
maktx LIKE makt-maktx,
matkl LIKE mara-matkl,
mtart LIKE mara-mtart,
END OF itab.
DATA : BEGIN OF itab1 OCCURS 0,
mtart LIKE mara-mtart,
count TYPE i,
END OF itab1.
DATA : BEGIN OF itab1_col OCCURS 0,
mtart LIKE mara-mtart,
count TYPE i,
END OF itab1_col.
DATA : t_fcat1 TYPE slis_t_fieldcat_alv,
t_fcat2 TYPE slis_t_fieldcat_alv,
wa_fcat TYPE slis_fieldcat_alv,
t_eve TYPE slis_t_event,
wa_eve TYPE slis_alv_event,
t_layout TYPE slis_layout_alv.
DATA : v_repid LIKE sy-repid,
t_mat LIKE mara-matnr.
DEFINE create_fcat.
clear wa_fcat.
wa_fcat-fieldname = &1.
wa_fcat-seltext_l = &2.
wa_fcat-outputlen = &3.
append wa_fcat to t_fcat1.
END-OF-DEFINITION.
START-OF-SELECTION.
PERFORM get_data.
PERFORM dis_data.
*& Form get_data
text
FORM get_data.
SELECT amatnr bmaktx amtart amatkl INTO CORRESPONDING FIELDS OF TABLE itab
FROM mara AS a INNER JOIN makt AS b ON
amatnr = bmatnr
WHERE a~matnr IN mat.
LOOP AT itab.
itab1-mtart = itab-mtart.
itab1-count = 1.
APPEND itab1.
ENDLOOP.
SORT itab1 BY mtart.
LOOP AT itab1.
MOVE-CORRESPONDING itab1 TO itab1_col.
COLLECT itab1_col.
ENDLOOP.
ENDFORM. "get_data
*& Form dis_data
text
FORM dis_data.
v_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = v_repid
i_callback_user_command = 'USER_COMMAND'.
REFRESH t_fcat1.
CLEAR t_fcat1.
REFRESH t_eve.
wa_eve-name = 'TOP_OF_PAGE'.
wa_eve-form = 'TOP_OF_PAGE1'.
APPEND wa_eve TO t_eve.
create_fcat:
'MATNR' 'Material' '10',
'MAKTX' 'Material Description' '40',
'MTART' 'Type' '10',
'MATKL' 'Group' '10'.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = t_layout
it_fieldcat = t_fcat1
i_tabname = 'ITAB'
it_events = t_eve
TABLES
t_outtab = itab.
REFRESH t_fcat1.
CLEAR t_fcat1.
REFRESH t_eve.
wa_eve-name = 'TOP_OF_PAGE'.
wa_eve-form = 'TOP_OF_PAGE2'.
APPEND wa_eve TO t_eve.
create_fcat:
'MTART' 'Type' '10',
'COUNT' 'Total' '5'.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = t_layout
it_fieldcat = t_fcat1
i_tabname = 'ITAB1_COL'
it_events = t_eve
TABLES
t_outtab = itab1_col.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
ENDFORM. "dis_data
**& Form user_command
text
-->U_COMM text
-->SELF text
FORM user_command USING u_comm TYPE sy-ucomm self TYPE slis_selfield.
CASE u_comm.
WHEN '&IC1'.
IF self-tabname = 'ITAB'.
READ TABLE itab INDEX self-tabindex.
t_mat = itab-matnr.
SET PARAMETER ID 'MAT' FIELD t_mat.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM. "user_command
*& Form top_of_page1
text
FORM top_of_page1.
FORMAT COLOR COL_POSITIVE.
WRITE:/ 'First Block'.
FORMAT COLOR OFF.
ENDFORM. "top_of_page
*& Form top_of_page2
text
FORM top_of_page2.
FORMAT COLOR COL_NEGATIVE.
WRITE /5 'Second Block'.
FORMAT COLOR OFF.
ENDFORM. "top_of_page
Here is the code for Classical Interactive........................
*& Report ZCLASSICAL_INTER
REPORT zclassical_inter.
TABLES : vbrk.
DATA : off TYPE i,
lin TYPE i,
fld TYPE char10.
DATA : BEGIN OF itab OCCURS 0,
vbeln LIKE vbrk-vbeln,
fkart LIKE vbrk-fkart,
fkdat LIKE vbrk-fkdat,
netwr LIKE vbrk-netwr,
kunag LIKE vbrk-kunag,
END OF itab.
TOP-OF-PAGE.
ULINE AT /1(80).
FORMAT COLOR 3 ON.
WRITE:/1 sy-vline,
3 'Billing Doc.',
18 sy-vline,
20 'Billing Type',
33 sy-vline,
35 'Billing Date',
48 sy-vline,
50 'Net Value',
68 sy-vline,
69 'Customer',
80 sy-vline.
ULINE AT /1(80).
FORMAT COLOR OFF.
START-OF-SELECTION.
SET PF-STATUS 'TEST'.
SELECT vbeln fkart fkdat netwr kunag FROM vbrk
INTO CORRESPONDING FIELDS OF TABLE itab
WHERE vbeln LIKE '00000033%'.
LOOP AT itab.
WRITE:/1 sy-vline,
itab-vbeln UNDER 'Billing Doc.' HOTSPOT ON,
18 sy-vline,
itab-fkart UNDER 'Billing Type',
33 sy-vline,
itab-fkdat UNDER 'billing Date',
48 sy-vline,
itab-netwr UNDER 'Net Value' LEFT-JUSTIFIED,
68 sy-vline,
itab-kunag UNDER 'Customer' HOTSPOT ON,
80 sy-vline.
HIDE : itab-vbeln.
HIDE : itab-kunag.
ENDLOOP.
ULINE AT /1(80).
AT LINE-SELECTION.
IF sy-lsind = 1.
PERFORM cal_vf03.
ENDIF.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'BACK' OR 'UP' OR 'CANC'.
LEAVE PROGRAM.
ENDCASE.
*& Form cal_vf03
text
FORM cal_vf03.
GET CURSOR LINE lin DISPLAY OFFSET off.
GET CURSOR FIELD fld. " DISPLAY OFFSET off LINE lin.
IF fld = 'ITAB-VBELN'.
SET PARAMETER ID 'VF' FIELD itab-vbeln.
CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN.
SET PARAMETER ID 'VF' FIELD space.
ELSEIF fld = 'ITAB-KUNAG'.
CALL TRANSACTION 'MIGO'.
ELSE.
CALL TRANSACTION 'MM03'.
ENDIF.
ENDFORM. "cal_vf03
reward if usefull...... -
HOw can we Call Subroutine in Sap Script?
HOw can we Call Subroutine in Sap Script?
Hi
*You have to call sub routine from script like this.
/: PERFORM DATE_FORMAT IN PROGRAM &SY-REPID&
/: USING &RM06P-LFDAT&
/: USING &PEKKO-LFDAT&
/: CHANGING &VALUE_OLD&
/: CHANGING &VALUE_NEW&
/: ENDPERFORM
*In print program write code.
FORM date_format TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
DATA : date TYPE char10.
DATA : date2 TYPE char10.
DATA : l_dmbtr TYPE char10.
READ TABLE in_tab WITH KEY 'RM06P-LFDAT'.
IF sy-subrc = 0.
"Your code goes here
CLEAR l_dmbtr.
ENDIF.
READ TABLE in_tab WITH KEY 'PEKKO-LFDAT'.
IF sy-subrc = 0.
l_dmbtr = in_tab-value.
"Your code goes here
CLEAR l_dmbtr.
ENDIF.
READ TABLE out_tab WITH KEY 'VALUE_NEW'.
IF sy-subrc EQ 0.
out_tab-value = date2.
MODIFY out_tab INDEX sy-tabix.
ENDIF.
READ TABLE out_tab WITH KEY 'VALUE_OLD'.
IF sy-subrc = 0.
out_tab-value = l_dmbtr.
MODIFY out_tab INDEX sy-tabix.
ENDIF.
ENDFORM. "DATE_FORMAT -
-ve sign in front without converting
Hi experts,
The negative sign of a currency field is being displayed at the end of the value I want it at the left, i.e at the begining of the value
<b>without converting it to a character type..</b>
i am aware of that FM : CLOI_PUT_SIGN_IN_FRONT but takes only character values
regards,
DanyHi,
Try this,
<b>DATA char TYPE char10.
DATA int TYPE i VALUE -10.</b>
<b>START-OF-SELECTION.</b>
<b>MOVE int TO char.</b>
<b>CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = char.</b>
<b>WRITE char.</b>
Or just Try this.
<b>WRITE int USING EDIT MASK '-___________'.</b>
The both result is <b>-10</b>.
Regards.
Marcelo Ramos -
Hi experts,
I am having one requiment i am creating one alv report whre i am displyaing ALV grid. So i hav some fields such as org. unit, personal no, position and job id.
so my requiment is i am haivng no of organiztional units i which there are no of peronnal nos and thir postion and job id.
so after completing of each org. i need to count the no of personal no.( here peronal no shows no of persons in that org. unit) so i need to count and display the no of persons in that org unit before staring of the next org. unit. and also i need to show the job id. job id is comman for all in that org. unit.
i hv to show one row at the end of each org unti showing cout of no of person and the job id.
just look at the format i needed.
Org Unit Personnel No.POSITION Job ID
5000001 1 6000001 700001
5000001 2 6000001 700001
<b>............ 2..........................700001</b>
5000002 3 6000002 700002
5000002 44 6000002 700002
5000002 42 6000002 700002
5000002 40 6000002 700002
<b>............ 4..........................700002</b>
note: i need to show the count of persons only . I dont need the sum of perons.
Here 500001, and 500002 are org units. and after completing one org unit. in the same filed personnal no it is showing count of that field and also job id (700001).
How to do in ALv grid display?
<REMOVED BY MODERATOR>
regards,
sunil kairam
Edited by: sunil kairam on Feb 19, 2008 10:50 AM
Edited by: Alvaro Tejada Galindo on Mar 4, 2008 4:05 PMHi check the below code
REPORT zmr_cpw NO STANDARD PAGE HEADING
LINE-SIZE 165
LINE-COUNT 65(2)
MESSAGE-ID zmm.
TABLE DECLARATION
*tables
TABLES: aufk, "Order master data
afvc, "Operations within an order
ekko, "purchasing docs
resb, "reservation/dep requirements
bapiret2. "Return parameter
SELECT-OPTIONS *
PARAMETERS *
*selection parameters
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
PARAMETERS: p_werks LIKE resb-werks OBLIGATORY. "plant
SELECT-OPTIONS: s_matnr FOR resb-matnr, "material
s_lifnr FOR afvc-lifnr, "vendor
s_erdat FOR aufk-erdat. "start date
SELECTION-SCREEN SKIP.
SELECT-OPTIONS: s_reswk FOR ekko-reswk NO-DISPLAY
DEFAULT '1301' OPTION EQ SIGN I. "whse
SELECTION-SCREEN END OF BLOCK b01.
SELECTION-SCREEN SKIP.
*plant report selections
SELECTION-SCREEN ULINE /10(55).
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 12(17) text-s00
FOR FIELD p_obplt.
PARAMETERS: p_obplt RADIOBUTTON GROUP rept.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 20(17) text-s01
FOR FIELD p_ptven.
PARAMETERS: p_ptven AS CHECKBOX.
SELECTION-SCREEN COMMENT 44(17) text-s02
FOR FIELD p_ptplt.
PARAMETERS: p_ptplt AS CHECKBOX.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
*vendor report selection
SELECTION-SCREEN ULINE /10(55).
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 12(17) text-s03
FOR FIELD p_obven.
PARAMETERS: p_obven RADIOBUTTON GROUP rept.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
*ALV data
TYPE-POOLS slis. "ALV list viewer
DATA: gs_sett TYPE lvc_s_glay,
gs_title TYPE lvc_title,
gx_vari TYPE disvariant,
g_vari TYPE disvariant,
d_extfg(1) TYPE c.
DATA: p_fieldcat TYPE slis_t_fieldcat_alv, "list
t_fieldcat TYPE slis_t_fieldcat_alv, "popup
s_fieldcat TYPE slis_fieldcat_alv,
t_extab TYPE slis_t_extab, "funct exclude
t_extab_x TYPE slis_t_extab,
s_extab TYPE slis_extab,
p_programname LIKE sy-repid.
*----- Processing options -
SELECTION-SCREEN BEGIN OF BLOCK b02 WITH FRAME TITLE text-002.
SELECTION-SCREEN SKIP.
PARAMETERS:
p_varia LIKE gx_vari-variant . "Layout
SELECTION-SCREEN END OF BLOCK b02.
DATA: count(2) TYPE n,
header2 TYPE char100,
header3 TYPE char100,
header4 TYPE char100,
datch TYPE char10, "date character
datfr TYPE char10, "reformat date
datto TYPE char10, "reformat date
qfield TYPE char14,
afield TYPE char14,
qtfld TYPE char3 VALUE 'qty',
amfld TYPE char3 VALUE 'dmb',
name1 LIKE lfa1-lifnr.
*internal tables
*BAPI messages
DATA: BEGIN OF t_bapiret2 OCCURS 0.
INCLUDE STRUCTURE bapiret2.
DATA: END OF t_bapiret2.
*-report data
DATA: BEGIN OF t_coredata OCCURS 0.
INCLUDE STRUCTURE zms_coredata.
DATA: flagd.
DATA: ebeln LIKE ekkn-ebeln.
DATA: END OF t_coredata.
DATA: t_coredata_x LIKE t_coredata OCCURS 0 WITH HEADER LINE.
*EKKO
DATA: BEGIN OF t_ekko OCCURS 0,
ebeln LIKE ekko-ebeln,
loekz LIKE ekko-loekz,
zzref LIKE ekko-zzref,
zzref_n LIKE ekko-ebeln,
flagd,
END OF t_ekko.
*-EKKN
DATA: BEGIN OF t_ekkn OCCURS 0,
ebeln LIKE ekkn-ebeln,
aufnr LIKE ekkn-aufnr,
END OF t_ekkn.
*-AUFK
DATA: BEGIN OF t_aufk OCCURS 0,
aufnr LIKE aufk-aufnr,
auart LIKE aufk-auart,
END OF t_aufk.
*descriptions
*-report
DATA: BEGIN OF t_report OCCURS 0,
codet LIKE dd03p-scrtext_m,
lifnr LIKE afvc-lifnr,
namel LIKE lfa1-name1,
aufnr LIKE mseg-aufnr,
auart LIKE aufk-auart,
aufnr_m LIKE mseg-aufnr,
auart_m LIKE aufk-auart,
erdat LIKE aufk-erdat,
matnr LIKE mseg-matnr,
maktx LIKE makt-maktx,
iloan LIKE zms_coredata-iloan,
tplnr LIKE zms_coredata-tplnr,
equnr LIKE zms_coredata-equnr,
eqktx LIKE zms_coredata-eqktx,
quans LIKE zms_coredata-quans,
sernr LIKE zms_coredata-sernr,
count TYPE i,
END OF t_report.
*-detail table
DATA: BEGIN OF t_detail_01 OCCURS 0,
aufnr LIKE mseg-aufnr,
aufnr_m LIKE mseg-aufnr,
ebeln LIKE ekko-ebeln,
matnr LIKE mseg-matnr,
END OF t_detail_01.
CONSTANTS DECLARATION *
CONSTANTS: c_yes TYPE char1 VALUE 'X',
c_nodesc TYPE name1 VALUE '**NO DESCRIPTION**',
c_pov LIKE zms_coredata-ocode VALUE 'POV',"Plant owes vendor
c_pop LIKE zms_coredata-ocode VALUE 'POP',"Plant owes plant
c_vop LIKE zms_coredata-ocode VALUE 'VOP',"Vendor owes plant
c_ub LIKE aufk-auart VALUE 'UB'.
HEADER *
TOP-OF-PAGE.
PERFORM top_of_page.
FOOTER *
INCLUDE zfooter.
END-OF-PAGE *
*END-OF-PAGE.
*PERFORM display_footer.
AT SELECTION-SCREEN.
*message if no reporting option is chosen for Owed by Plant
IF NOT p_obplt IS INITIAL.
IF p_ptven IS INITIAL
AND p_ptplt IS INITIAL.
MESSAGE e000(zmm) WITH text-m02.
ENDIF.
ENDIF.
----- At selection screen on value request for "Layout" -
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varia.
PERFORM select_layout.
START-OF-SELECTION
START-OF-SELECTION.
*retrieve CORE data using BAPI
PERFORM get_core_data.
*build report table
PERFORM report_table.
END-OF-SELECTION.
LIST PROCESSING *
*write report
*-heading data
PERFORM heading_data.
PERFORM alv_list_viewer.
SUBROUTINES *
*forms
*& Form get_CORE_DATA
FORM get_core_data.
CALL FUNCTION 'ZMM_BAPI_GET_CORE_OWEAGE'
EXPORTING
bapi_plant = p_werks
TABLES
bapi_rangesmatnr = s_matnr
bapi_rangeslifnr = s_lifnr
bapi_rangesbldat = s_erdat
bapi_rangesreswk = s_reswk
coredata = t_coredata
return = t_bapiret2.
*Vendor owes Plant
IF NOT p_obven IS INITIAL.
DELETE t_coredata WHERE NOT ocode = c_vop.
EXIT.
ENDIF.
*Plant owes
IF NOT p_obplt IS INITIAL.
DELETE t_coredata WHERE ocode = c_vop.
ENDIF.
*Plant owes vendor
IF NOT p_ptven IS INITIAL.
t_coredata-flagd = c_yes.
MODIFY t_coredata TRANSPORTING flagd WHERE ocode = c_pov. "keep
ENDIF.
*Plant owes plant
IF NOT p_ptplt IS INITIAL.
t_coredata-flagd = c_yes.
MODIFY t_coredata TRANSPORTING flagd WHERE ocode = c_pop. "keep
ENDIF.
DELETE t_coredata WHERE flagd IS INITIAL.
*-get additional data
t_coredata_x[] = t_coredata[].
DELETE t_coredata_x WHERE NOT auart = c_ub. "STO
CHECK NOT t_coredata_x[] IS INITIAL.
LOOP AT t_coredata_x.
t_coredata_x-ebeln = t_coredata_x-aufnr.
MODIFY t_coredata_x TRANSPORTING ebeln.
ENDLOOP.
*-get CORE Stock Transport Orders for display
SELECT ebeln loekz zzref
INTO TABLE t_ekko
FROM ekko
WHERE reswk = p_werks.
DELETE t_ekko WHERE NOT loekz IS INITIAL.
DELETE t_ekko WHERE zzref IS INITIAL. "not create w/ref to STO
*reformat field
LOOP AT t_ekko.
t_ekko-zzref_n = t_ekko-zzref(10).
MODIFY t_ekko TRANSPORTING zzref_n.
ENDLOOP.
SORT t_ekko BY zzref_n.
*--Mine Maintenance Order
SELECT ebeln aufnr
INTO TABLE t_ekkn
FROM ekkn
FOR ALL ENTRIES IN t_coredata_x
WHERE ebeln = t_coredata_x-ebeln.
DELETE t_ekkn WHERE aufnr IS INITIAL.
CHECK NOT t_ekkn[] IS INITIAL.
*--Mine Maintenance Order Type
SELECT aufnr auart
INTO TABLE t_aufk
FROM aufk
FOR ALL ENTRIES IN t_ekkn
WHERE aufnr = t_ekkn-aufnr.
ENDFORM. " get_CORE_DATA
*& Form report_table
FORM report_table.
*create report table
SORT t_ekkn BY ebeln.
SORT t_aufk BY aufnr.
LOOP AT t_coredata.
CLEAR t_report.
MOVE-CORRESPONDING t_coredata TO t_report.
*Mine maint order
IF t_report-auart = c_ub.
READ TABLE t_ekkn WITH KEY ebeln = t_report-aufnr BINARY SEARCH.
IF sy-subrc = 0.
t_report-aufnr_m = t_ekkn-aufnr.
READ TABLE t_aufk WITH KEY aufnr = t_ekkn-aufnr BINARY SEARCH.
IF sy-subrc = 0.
t_report-auart_m = t_aufk-auart.
ENDIF.
ENDIF.
ENDIF.
CASE t_coredata-ocode.
WHEN c_pop.
t_report-codet = text-s02.
WHEN c_pov.
t_report-codet = text-s01.
WHEN c_vop.
t_report-codet = text-s03.
ENDCASE.
Add 1 to the count column to use with totaling
t_report-count = '1'.
APPEND t_report.
ENDLOOP.
ENDFORM. " report_table
*& Form ALV_list_viewer
FORM alv_list_viewer.
IF t_report[] IS INITIAL.
WRITE: text-m01.
ENDIF.
CHECK NOT t_report[] IS INITIAL.
SORT t_report BY lifnr matnr aufnr sernr.
PERFORM function_exclude. "this is for the popup view
Call ABAP List Viewer (ALV)
p_programname = sy-repid.
gx_vari-report = sy-repid.
gx_vari-username = sy-uname.
gx_vari-variant = p_varia.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = p_programname
i_internal_tabname = 'T_REPORT'
i_inclname = p_programname
CHANGING
ct_fieldcat = p_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
PERFORM field_catalog TABLES p_fieldcat.
gs_sett-top_p_only = 'X'.
CONCATENATE header3 header4 INTO gs_title SEPARATED BY space.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gx_vari-report
i_callback_top_of_page = 'TOP_OF_PAGE'
i_callback_user_command = 'USER_COMMAND'
i_grid_settings = gs_sett
i_structure_name = 'T_REPORT'
i_grid_title = gs_title
is_variant = gx_vari
i_save = 'A'
it_fieldcat = p_fieldcat[]
TABLES
t_outtab = t_report.
ENDFORM. " ALV_list_viewer
*& Form field_catalog
FORM field_catalog TABLES p_fieldcat TYPE slis_t_fieldcat_alv.
LOOP AT p_fieldcat INTO s_fieldcat.
CASE s_fieldcat-fieldname.
WHEN 'CODET'.
s_fieldcat-seltext_s = 'Oweage'.
s_fieldcat-seltext_m = 'Oweage'.
s_fieldcat-seltext_l = 'Oweage'.
s_fieldcat-reptext_ddic = 'Oweage'.
WHEN 'NAMEL'.
s_fieldcat-seltext_s = 'Name'.
s_fieldcat-seltext_m = 'Name'.
s_fieldcat-seltext_l = 'Name'.
s_fieldcat-reptext_ddic = 'Name'.
WHEN 'AUFNR_M'.
s_fieldcat-seltext_s = 'MineOrd'.
s_fieldcat-seltext_m = 'Mine Order'.
s_fieldcat-seltext_l = 'Mine Maint Order'.
s_fieldcat-reptext_ddic = 'Mine Order'.
WHEN 'AUART_M'.
s_fieldcat-seltext_s = 'MineOrdTyp'.
s_fieldcat-seltext_m = 'Mine Order Type'.
s_fieldcat-seltext_l = 'Mine Maint Order Type'.
s_fieldcat-reptext_ddic = 'Mine Order Type'.
WHEN 'EBELN'.
s_fieldcat-seltext_s = 'CORE STO'.
s_fieldcat-seltext_m = 'CORE STO'.
s_fieldcat-seltext_l = 'CORE Stock Transport Order'.
s_fieldcat-reptext_ddic = 'CORE STO'.
s_fieldcat-key = ' '.
WHEN 'COUNT'.
s_fieldcat-seltext_s = 'COUNT'.
s_fieldcat-seltext_m = 'COUNT'.
s_fieldcat-seltext_l = 'COUNT'.
s_fieldcat-reptext_ddic = 'COUNT'.
s_fieldcat-key = ' '.
ENDCASE.
MODIFY p_fieldcat FROM s_fieldcat.
ENDLOOP.
ENDFORM. " field_catalog
*& Form heading_data
FORM heading_data.
*-heading data
header2 = text-h01.
*-format date range
IF s_erdat[] IS INITIAL.
SORT t_report BY erdat.
READ TABLE t_report INDEX 1.
s_erdat-low = t_report-erdat.
SORT t_report BY erdat DESCENDING.
READ TABLE t_report INDEX 1.
s_erdat-high = t_report-erdat.
APPEND s_erdat.
ENDIF.
READ TABLE s_erdat INDEX 1.
WRITE s_erdat-low TO datfr.
WRITE s_erdat-high TO datto.
CONCATENATE datfr 'to' datto
INTO header3 SEPARATED BY space.
*plant
READ TABLE t_coredata INDEX 1.
CONCATENATE p_werks t_coredata-namew
INTO header4 SEPARATED BY space.
ENDFORM. " heading_data
*& Form top_of_page
FORM top_of_page.
CALL FUNCTION 'Z_REPORT_HEADER'
EXPORTING
header2 = header2
header3 = header3
header4 = header4.
ENDFORM. " top_of_page
*& Form user_command
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
*F2
CHECK r_ucomm = '&IC1'.
*field deterimines further action
CASE rs_selfield-sel_tab_field.
WHEN 'T_REPORT-AUFNR'. "if STO - display CORE STO
READ TABLE t_report INDEX rs_selfield-tabindex.
CHECK t_report-auart = c_ub."only if order is STO
REFRESH t_detail_01.
LOOP AT t_ekko
WHERE zzref_n = t_report-aufnr.
t_detail_01-aufnr = t_report-aufnr.
t_detail_01-aufnr_m = t_report-aufnr_m.
t_detail_01-ebeln = t_ekko-ebeln.
t_detail_01-matnr = t_report-matnr.
APPEND t_detail_01.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = p_programname
i_internal_tabname = 'T_DETAIL_01'
i_inclname = p_programname
CHANGING
ct_fieldcat = t_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
PERFORM field_catalog TABLES t_fieldcat.
t_extab_x[] = t_extab[].
*these are the FCodes to keep on the popup screen
DELETE t_extab_x WHERE fcode = '&AC1'. "cancel
DELETE t_extab_x WHERE fcode = '%SC'. "find
DELETE t_extab_x WHERE fcode = '%SC+'. "repeat find
DELETE t_extab_x WHERE fcode = '&OUP'. "sort asc
DELETE t_extab_x WHERE fcode = '&ODN'. "sort desc
SORT t_detail_01 BY ebeln.
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
i_title = text-h02
i_tabname = 'T_DETAIL_01'
it_fieldcat = t_fieldcat[]
it_excluding = t_extab_x
TABLES
t_outtab = t_detail_01.
ENDCASE.
ENDFORM. " user_command
*& Form function_exclude
FORM function_exclude.
*this form excludes all functions on popup screen
*delete entries that should appear on the popup from this table prior to
*REUSE_ALV_POPUP_TO_SELECT
s_extab-fcode = '&ONT'. "copy/enter
APPEND s_extab TO t_extab.
s_extab-fcode = '&ETA'. "detail
APPEND s_extab TO t_extab.
s_extab-fcode = '%SC'. "find
APPEND s_extab TO t_extab.
s_extab-fcode = '%SC+'. "find next
APPEND s_extab TO t_extab.
s_extab-fcode = '&OUP'. "sort asc
APPEND s_extab TO t_extab.
s_extab-fcode = '&ODN'. "sort desc
APPEND s_extab TO t_extab.
s_extab-fcode = '&ILT'. "filter
APPEND s_extab TO t_extab.
s_extab-fcode = '&OL0'. "display variant
APPEND s_extab TO t_extab.
s_extab-fcode = '&CRB'. "H scroll-1st
APPEND s_extab TO t_extab.
s_extab-fcode = '&CRL'. "H scroll-prev
APPEND s_extab TO t_extab.
s_extab-fcode = '&CRR'. "H scroll-next
APPEND s_extab TO t_extab.
s_extab-fcode = '&CRE'. "H scroll-last
APPEND s_extab TO t_extab.
s_extab-fcode = '&AC1'. "Cancel
APPEND s_extab TO t_extab.
s_extab-fcode = '&ALL'. "select all
APPEND s_extab TO t_extab.
s_extab-fcode = '&SAL'. "deselect all
APPEND s_extab TO t_extab.
ENDFORM. " function_exclude
Maybe you are looking for
-
Adobe webdynpro taking time too long
Hi, Initially, I have Read Timed Out issue. I;ve incresed the Web Container timeout to 360 seconds. but now, when I run the program with Interavtive form, it tooks very long time. It's been 30 minutes and still going. I do see the log mentioned not f
-
Interface mapping - Not specified
I am able to create the interface determination. But I am not able to associate my Interface mapping to the Inbound interface. After I selected a Inbound interface in the Interface determination, I clicked on the mapping option, but 'No objects found
-
What's with the ios compatibility changes??
ios 7 was available for iPod 4 when 1st announced that the new software was coming out....but only for the 16g and up iPod 4 bought my kid an iPod 4 last Christmas and now she can't update! Not cool Apple!!! If the update is available for other devic
-
moved from photoshop forum jenny waller Jan 27, 2015 8:09 AM , i have been trying for years to install acr 6.7 and no luck. mac 10.0.4 pse ver 10. i have downloaded acr 6.7 (says installed successful) shows up in my download files. then click
-
Hi all, After deleting any rows/row in the WebDynpro table it is showing one blank row showing the presence of row there already. This blank row is appearing when we add new row next time. I don't want to appear this blank line after delet