Record appending Blank in internal table....
Hi Experts,
The below loop is appending blank in table aufnr_tab. What is wrong in it ?
Loop at lts_objnr.
SELECT SINGLE aufnr plnbez INTO CORRESPONDING FIELDS OF aufnr_tab
FROM caufv
where aufpl = lts_objnr-aufpl
AND AUTYP = '10'
AND LOEKZ <> 'X'
AND aufnr = '000001011267'.
aufnr_tab-aufnr = caufv-aufnr.
aufnr_tab-plnbez = caufv-plnbez.
Append aufnr_tab.
Endloop.
YAB
Yusuf,
You seem to be looking for just one specific record in table view CAUFV (where the order number AUFNR = 000001011267). Are you sure this is what you are looking to do? I believe that you might want to get rid of the clause '<b>AND aufnr = '000001011267'.</b>' If indeed you are just looking for one record I don't see why you need to retrieve it so many times (within a loop). For table view CAUFV, field AUFNR is the primary key. You are likely to get just one record with AUFNR = 000001011267.
I think your logic should be something like this.
TYPES: BEGIN OF ty_caufv,
aufpl TYPE caufv-aufpl,
aufnr TYPE caufv-aufnr,
plnbez TYPE caufv-plnbez,
END OF ty_caufv.
DATA: w_caufv TYPE ty_caufv,
lts_caufv TYPE SORTED TABLE OF ty_caufv
WITH NON-UNIQUE KEY aufpl,
lts_objnr_tmp LIKE TABLE OF lts_objnr.
IF NOT lts_objnr[] IS INITIAL.
lts_objnr_tmp[] = lts_objnr[].
SORT lts_objnr_tmp BY aufpl.
DELETE ADJACENT DUPLICATES FROM lts_objnr_tmp COMPARING aufpl.
SELECT aufpl
aufnr
plnbez
FROM caufv
INTO TABLE t_caufv
FOR ALL ENTRIES IN lts_objnr_tmp
WHERE autyp EQ '10'
AND loekz NE 'X'
AND aufpl EQ lts_objnr_tmp-aufpl.
ENDIF.
REFRESH aufnr_tab.
LOOP AT lts_objnr.
READ TABLE lts_caufv INTO w_caufv
WITH KEY aufpl = lts_objnr-aufpl.
IF sy-subrc EQ 0.
aufnr_tab-aufnr = w_caufv-aufnr.
aufnr_tab-plnbez = w_caufv-plnbez.
APPEND aufnr_tab.
ENDIF.
ENDLOOP.
Similar Messages
-
OTF to PDF - Getting blank PDF Internal table with CONVERT_OTF func module
All
i've captured OTF from smartforms and tried converting to PDF through 'CONVERT_OTF_2_PDF' FUNCTIOn module and after emailing to external email id, i found logo is completely disturbed (characters in logo got mixed up)..... later i tried converting with ''CONVERT_OTF' function module, but here i'm getting blank PDF internal table....
what am i missing in both ?
my intention is converting otf to pdf and emailing...though there are thousands of similar threads are available , none of them are related to my exact problem, which is logo is getting mixed up or disturbed.... any suggestions ?
Thanks in advanceHi,
You need to use the function module SX_OBJECT_CONVERT_OTF_PDF to create the PDF from OTF ..
Here is an example program
report ZPDFPRNT no standard page heading.
TABLES: TST05.
DATA: BEGIN OF ITAB OCCURS 0,
TLINE(255),
END OF ITAB.
DATA: BEGIN OF ITAB2 OCCURS 0,
TLINE(255),
END OF ITAB2.
DATA: BEGIN OF ITAB3 OCCURS 0,
TLINE(255),
END OF ITAB3.
DATA: BEGIN OF OTF_TAB OCCURS 0,
TLINE(255),
END OF OTF_TAB.
DATA: LEN_OUT LIKE SOOD-OBJLEN.
DATA: LEN_IN LIKE SOOD-OBJLEN.
DATA: BEGIN OF DATA_SET OCCURS 200,
DATA_LENGTH(5),
PRECOL(1),
DATA_LINE(1000),
END OF DATA_SET.
DATA: BEGIN OF OTF_PAGE OCCURS 200.
INCLUDE STRUCTURE ITCOO.
DATA: END OF OTF_PAGE,
OTF_PAGES TYPE P,
OTF_MAX_PAGES TYPE P VALUE 10.
DATA: BEGIN OF OTF_CONTROL.
INCLUDE STRUCTURE ITCPP.
DATA: END OF OTF_CONTROL,
FORCE_RAW_OTF VALUE ' ',
L100_EXCLUDE(4) VALUE 'OTFJ',
BEGIN OF OTF_PAGE_INDEX OCCURS 20,
LINE_NUM TYPE P,
END OF OTF_PAGE_INDEX,
CUR_OTF_PAGE VALUE 1.
DATA: DATA_SET_LINECOUNT TYPE P,
DATA_SET_MAX_LINES TYPE P VALUE 100000,
DATA_SET_VALID TYPE C VALUE ' ',
DATA_SET_IS_OTF TYPE C VALUE ' ',
DATA_SET_LENGTH(5) TYPE C,
LINE_SPECIAL LIKE DATA_SET-DATA_LINE,
NEED_LINE_SPECIAL TYPE C,
DSN_TYPE(8) TYPE C.
DATA: FCODE(4) TYPE C,
DATE TYPE D,
TIME TYPE T,
RC(10) TYPE C,
ERRMSG(100) TYPE C,
PRINTJOB_CREATED(1) TYPE C,
PRINTJOB_CLEARED(1) TYPE C,
PRINTJOB_LIST(1) TYPE C,
DISPLAY_MODE(1) TYPE C,
LINE_MAX TYPE P VALUE '100000',
NEW_SCREEN_300(1) TYPE C,
MULTI_PRINT_300(1) TYPE C,
PRINT_ALL_300(1) TYPE C,
PRINT_COUNT_300 TYPE I,
SHOW_USER_100 TYPE C VALUE ' ',
ERROR_DISPLAY_LEVEL TYPE C VALUE '9',
NEXT_ERROR_DISPLAY_LEVEL TYPE C,
PREV_ERROR_DISPLAY_LEVEL TYPE C,
START_300(5) TYPE C, END_300(5) TYPE C,
SEP LIKE SY-VLINE,
DEFAULT_PRI,
TSP01_BUF LIKE TSP01,
TSP01_CURLINE LIKE SY-STARO,
TSP01_CURCOL LIKE SY-CUCOL,
TSP01_CURROW LIKE SY-CUROW.
DATA: BEGIN OF DATA_SET_LINE,
DATA_LENGTH(5),
PRECOL(1),
DATA_LINE(1000),
END OF DATA_SET_LINE.
DATA: STATUS LIKE SY-SUBRC.
DATA: WGF_MESSAGE(80).
DATA: H_PATH(20) TYPE C.
DATA: H_MASK(20) TYPE C VALUE ',.pdf ,.pdf. '.
DATA: FILE_NAME(20).
DATA: FILENAME LIKE RLGRAP-FILENAME.
DATA: IMPORT(132).
PARAMETERS: IDENT(5) TYPE C.
PERFORM GET_OTF_TAB.
LOOP AT OTF_PAGE.
OTF_TAB-TLINE = OTF_PAGE.
APPEND OTF_TAB.
ENDLOOP.
CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
EXPORTING
FORMAT_SRC = 'OTF'
FORMAT_DST = 'PDF'
DEVTYPE = 'ASCIIPRI'
LEN_IN = LEN_IN
IMPORTING
LEN_OUT = LEN_OUT
TABLES
CONTENT_IN = OTF_TAB
CONTENT_OUT = ITAB2
EXCEPTIONS
ERR_CONV_FAILED = 1
OTHERS = 2.
PERFORM GET_PATH USING 'PDF_FILE'.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = FILENAME
FILETYPE = 'BIN'
BIN_FILESIZE = LEN_OUT
TABLES
DATA_TAB = ITAB2
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
OTHERS = 8.
*& Form GET_OTF_TAB
FORM GET_OTF_TAB.
DATA: PART(4) VALUE '0001',
BEGIN OF MSG,
A(40),
B(40),
C(40),
END OF MSG.
REFRESH DATA_SET.
DATA_SET_LINECOUNT = 0.
DATA_SET_IS_OTF = ' '.
OTF_PAGES = 0.
REFRESH OTF_PAGE_INDEX.
CALL 'RSPOACSD'.
SELECT * FROM TST05 WHERE DTHREAD = 'X'.
CALL 'RSPOAOSD'
ID 'ID' FIELD IDENT
ID 'TYPE' FIELD TST05-DTYPE
ID 'RECTYP' FIELD 'VYL----'
ID 'RC' FIELD RC
ID 'ERRMSG' FIELD ERRMSG.
STATUS = SY-SUBRC.
IF STATUS = 0.
DSN_TYPE = TST05-DTYPE.
IF DSN_TYPE(3) = 'OTF'.
DATA_SET_IS_OTF = 'X'.
ENDIF.
ENDIF.
IF STATUS <> 24. EXIT. ENDIF.
ENDSELECT.
DATA_SET_VALID = 'X'.
DATA_SET_MAX_LINES = ( LINE_MAX * '1.1' ) + 100.
DO.
CLEAR: DATA_SET_LINE, DATA_SET_LENGTH.
CALL 'RSPOARSD'
ID 'BUFF' FIELD DATA_SET_LINE+5
ID 'DATALEN' FIELD DATA_SET_LENGTH
ID 'RC' FIELD RC
ID 'ERRMSG' FIELD ERRMSG.
STATUS = SY-SUBRC.
IF STATUS = 36.
WHILE STATUS = 36.
CALL 'RSPOACSD'
ID 'RC' FIELD RC
ID 'ERRMSG' FIELD ERRMSG.
ADD 1 TO PART.
IF DATA_SET_IS_OTF = ' '.
CALL 'RSPOAOSD'
ID 'ID' FIELD IDENT
ID 'TYPE' FIELD DSN_TYPE
ID 'PART' FIELD PART
ID 'RECTYP' FIELD 'VYL----'
ID 'RC' FIELD RC
ID 'ERRMSG' FIELD ERRMSG.
ELSE.
CALL 'RSPOAOSD'
ID 'ID' FIELD IDENT
ID 'PART' FIELD PART
ID 'TYPE' FIELD DSN_TYPE
ID 'RECTYP' FIELD 'VYL----'
ID 'RC' FIELD RC
ID 'ERRMSG' FIELD ERRMSG.
ENDIF.
IF SY-SUBRC NE 0. EXIT. ENDIF.
CLEAR: DATA_SET_LINE, DATA_SET_LENGTH.
CALL 'RSPOARSD'
ID 'BUFF' FIELD DATA_SET_LINE+5
ID 'DATALEN' FIELD DATA_SET_LENGTH
ID 'RC' FIELD RC
ID 'ERRMSG' FIELD ERRMSG.
STATUS = SY-SUBRC.
ENDWHILE.
ENDIF.
IF STATUS <> 0 AND STATUS <> 40. EXIT. ENDIF.
DATA_SET = DATA_SET_LINE.
IF NOT ( DATA_SET_LENGTH IS INITIAL ).
DATA_SET-DATA_LENGTH = DATA_SET_LENGTH - 1.
ENDIF.
APPEND DATA_SET.
ADD 1 TO DATA_SET_LINECOUNT.
IF DATA_SET_IS_OTF = ' '.
IF DATA_SET_LINECOUNT >= DATA_SET_MAX_LINES.
CLEAR DATA_SET.
APPEND DATA_SET.
MOVE '----
' TO DATA_SET-DATA_LINE.
APPEND DATA_SET.
CLEAR DATA_SET.
APPEND DATA_SET.
WRITE: 'Abbruch nach'(029) TO MSG-A.
WRITE: DATA_SET_MAX_LINES TO MSG-B.
WRITE: 'Zeilen.'(030) TO MSG-C.
CONDENSE MSG.
DATA_SET-DATA_LINE = MSG.
APPEND DATA_SET.
EXIT.
ENDIF.
ELSE.
MOVE DATA_SET_LINE-DATA_LINE TO OTF_PAGE.
APPEND OTF_PAGE.
IF OTF_PAGE(2) = 'EP'.
ADD 1 TO OTF_PAGES.
IF OTF_PAGES >= OTF_MAX_PAGES.
MESSAGE S229(PO) WITH OTF_MAX_PAGES.
EXIT.
ENDIF.
ELSEIF OTF_PAGE(2) = 'OP'.
OTF_PAGE_INDEX-LINE_NUM = DATA_SET_LINECOUNT.
APPEND OTF_PAGE_INDEX.
ENDIF.
ENDIF.
ENDDO.
IF STATUS <> 0 AND STATUS <> 12.
CALL 'RSPOACSD'.
MESSAGE E112(PO) WITH STATUS RC ERRMSG.
ENDIF.
CALL 'RSPOACSD'.
STATUS = SY-SUBRC.
IF STATUS <> 0.
MESSAGE E112(PO) WITH STATUS RC ERRMSG.
ENDIF.
ENDFORM. " GET_OTF_TAB
*& Form GET_PATH
FORM GET_PATH USING P_FILENAME.
CLEAR: H_PATH, FILE_NAME.
FILE_NAME = P_FILENAME.
CALL FUNCTION 'WS_QUERY'
EXPORTING
QUERY = 'CD' "// Current Directory
IMPORTING
RETURN = H_PATH.
CONCATENATE FILE_NAME '.pdf' INTO FILE_NAME.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = FILE_NAME
DEF_PATH = H_PATH
MASK = H_MASK
MODE = 'O'
IMPORTING
FILENAME = FILENAME"dbname
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
ENDFORM. " GET_PATH
Regards
Sudheer -
Urgent - Append data to internal table from Application server
Hi All,
I encountered the problem while read the input file from Application server...then append it to internal table. I manage to read the input file from presentation and append the data to internal table.
Below are my coding which cause me not able the append data from Application server. Please kindly help me to solving/correct my coding. Thanks in advance .
PARAMETERS : p_inpfl LIKE rlgrap-filename. "Material Input File
SELECTION-SCREEN BEGIN OF LINE.
Application Server
SELECTION-SCREEN COMMENT 1(19) text-002 FOR FIELD rb_ux.
SELECTION-SCREEN POSITION 33.
PARAMETERS: rb_ux RADIOBUTTON GROUP g1.
Presentation Server
SELECTION-SCREEN COMMENT 40(21) text-003 FOR FIELD rb_pc.
SELECTION-SCREEN POSITION 65.
PARAMETERS: rb_pc RADIOBUTTON GROUP g1 DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK b01.
FORM f_Input_file.
CLEAR: v_f_exists.
CHECK NOT p_inpfl IS INITIAL. "input file exist
IF NOT rb_pc IS INITIAL. " Pc check
PERFORM f_read_tab_delimited_file TABLES i_input
USING c_09
p_inpfl
rb_ux
CHANGING v_ifile_str_with_tab
v_f_exists
v_ifile_record_count
v_message.
IF v_f_exists EQ '1' .
UPLOAD FILE could not be read
MESSAGE e546 .
ENDIF .
IF v_ifile_record_count EQ 0 .
Zero records in upload file
MESSAGE e547 .
ENDIF.
ELSE.
OPEN DATASET p_inpfl FOR INPUT IN TEXT MODE.
DO.
READ DATASET p_inpfl INTO i_input.
IF sy-subrc EQ 0.
APPEND i_input.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET p_inpfl.
ENDIF.Hi,
Refere the following code for the poulating internal from the application server.
PARAMETERS : pr_sfile TYPE filename-fileintern,
Here give the logical file name from the application serevr.
data : w_param_1 LIKE filename-fileintern,
x_file(500),
w_move_file LIKE epsf-epsfilnam,
w_from_dir LIKE epsf-epsdirnam,
w_path LIKE rlgrap-filename,
input_line(1000),
w_path LIKE rlgrap-filename,
w_file LIKE rlgrap-filename,
w_dir LIKE rlgrap-filename,
w_dir1 LIKE epsf-epsdirnam,
w_file1 LIKE epsf-epsfilnam,
**************Start of the code***************
MOVE '*' TO w_param_1.
PERFORM get_file_name USING pr_sfile w_param_1.
LOOP AT it_file WHERE name CP w_file1.
CLEAR : x_file, w_path,
w_move_file, w_from_dir.
REFRESH : it_input,
it_input_err.
IF w_flag IS INITIAL.
CONCATENATE w_dir it_file-name INTO x_file.
CONDENSE x_file.
TO Move file from sever for backup storing the file name and path
w_path = x_file.
CALL FUNCTION 'TRINT_SPLIT_FILE_AND_PATH'
EXPORTING
full_name = x_file
IMPORTING
stripped_name = w_move_file
file_path = w_from_dir
EXCEPTIONS
x_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.
********here it_input will be the structure of the file present on the application server
PERFORM read_file TABLES it_input
USING x_file.
CLEAR it_input_err.
REFRESH it_input.
ENDLOOP.
*******************end of the code****************
*& Form read_file
text
-->P_X_FILE text
FORM read_file TABLES it_tab
USING x_file.
OPEN DATASET x_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
WRITE : / text-006.
ELSE.
DO.
READ DATASET x_file INTO input_line.
IF sy-subrc = 0.
CLEAR: it_input, count.
DO.
ADD 1 TO count.
ASSIGN COMPONENT count OF STRUCTURE it_tab TO <fs>.
IF sy-subrc = 0.
SPLIT input_line AT separator INTO <fs> input_line.
ELSE.
EXIT.
ENDIF.
ENDDO.
APPEND it_tab.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET x_file.
*& Form get_file_name
text
-->P_P_SFILE text
-->P_W_PARAM_1 text
FORM get_file_name USING p_sfile
w_param_1.
CHANGING x_file.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
client = sy-mandt
logical_filename = p_sfile
parameter_1 = w_param_1
IMPORTING
file_name = x_file
EXCEPTIONS
file_not_found = 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.
w_path = x_file.
CALL FUNCTION 'TRINT_SPLIT_FILE_AND_PATH'
EXPORTING
full_name = w_path
IMPORTING
stripped_name = w_file
file_path = w_dir
EXCEPTIONS
x_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.
w_dir1 = w_dir.
w_file1 = w_file.
CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
EXPORTING
dir_name = w_dir1
file_mask = w_file1
TABLES
dir_list = it_file
EXCEPTIONS
invalid_eps_subdir = 1
sapgparam_failed = 2
build_directory_failed = 3
no_authorization = 4
read_directory_failed = 5
too_many_read_errors = 6
empty_directory_list = 7
OTHERS = 8.
IF sy-subrc <> 0.
WRITE : / text-006.
ENDIF.
Hope this will help you. -
i m calling one FM inside the loop, this FM will return data in internal table. for each loop count i want to save this data to same other internal table, how to do that?
i want to append the one internal tables data to another internal table how to do that?
ThanksHi Lucky,
Refer this code :
LOOP AT I_TAB1.
CALL FUNCTION <FUNCTION NAME>
EXPORTING
IMPORTING
TABLES = I_TAB2.
APEEND LINES OF I_TAB2 to I_TAB3.
REFRESH I_TAB2.
ENDLOOP.
REWARD POINTS IF HELPFUL.
Regards,
Hemant -
How to Read records from structure to internal table
HI,
Can any body know how to read the records from structure to internal table at runtime.
please give me sample program if possible.
thanks in advance
KPif your internal table is having the same structure as the structure you are reading the values from then you can directly assign like..
internatable table work area or header line = structure.
or else if they are different assign field by field like
internal table-field1 = structure-field1.
internal table-field2 = structure-field2.
award points if it helps. -
Selecting multiple records from the list and append it into internal table.
hi
there is a list of 10 records in the output screen with check boxes. if the user select any 3 records then those records should get appended in some other internal table of same structure.
this is the requirement. can anybody help me it is very urgent.
regards
samiHi,
Loop at the internal table which contains the value in table control and move it to a work area. apend the work area to the next internal table. Like:
loop at it1 into wa1 where sel = 'X'.
append wa1 to it2.
endloop.
or
loop at it1 into wa1.
if wa1-sel = 'X'.
append wa1 to it2.
endif.
endloop.
Regards,
RM -
Reg : Joining the all internal table records into a single internal table
Hi all
I am having 5 internal tables and i want to put all these entries in a single intrnal table and my requirement is for each and every record it has to go through all the internal tables and if an entry is missing meand.it has to go through the other internal tables and for missing entries i should leave it as blank and rest of the contents i have to display can any please gimme some logic how to do this??
Thanks in advanceDon't have time or will to deliver turnkey solutions, but here is a frame:
LOOP AT itab1...
READ TABLE itab2 WITH TABLE KEY... (fields linking itab1 and itab2)
READ TABLE itab3 WITH TABLE KEY... (fields linking itab1 and itab3)
LOOP AT itab4 WHERE... (fields linking itab1 and itab4)
READ TABLE itab5 WITH TABLE KEY... (fields linking itab4 and itab5)
MOVE-CORRESPONDING... (all five work areas to target work area)
APPEND itabtarget...
ENDLOOP.
ENDLOOP.
so use READ when there is a 1:1 relationship (e.g. check table entry), and LOOP when there is a 1:N relationship (e.g. items for a header)
Thomas -
ALV GRID Report is not showing all records which is in internal table
hi all,
have one doubt. please clarify me. ALV Report is working fine since long tiem. But suddenly this report is showing few records only for the given input. Example: it_main table have 50 records, but output is showing only 10 records only. (we have not made any modifications in this report).
temporarily i have given excel output file from it_main table. excel file is showing all records.
here it_main have all the records. but output is showing few records only. it is not showing any error. i have tested with REUSE_ALV_LIST_DISPLAY function also. but it also showing same results(few records only.)
please give me some idea.
FORM display_alv_report.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_buffer_active = 'X'
i_callback_program = sy-repid
is_layout = wa_layout
it_fieldcat = it_fcat
it_events = it_events
i_save = 'A'
is_variant = wa_variant
TABLES
t_outtab = it_main
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE text-204 " 'Error in Display the list'
TYPE 'I'.
LEAVE TO LIST-PROCESSING.
ENDIF.
ENDFORM. . "DISPLAY_ALV_REPORT
Best Regards,
Srinivashi
Please study this program and give me suggestions.
ALV Declaration
DATA : it_events TYPE slis_t_event, "ALV event
it_fcat TYPE slis_t_fieldcat_alv, "Field catalog
it_list_top_of_page TYPE slis_t_listheader,
c_tabname TYPE slis_tabname VALUE 'IT_MAIN'.
DATA : wa_layout TYPE slis_layout_alv,
wa_event TYPE slis_alv_event,
wa_fcat TYPE slis_fieldcat_alv,
wa_variant TYPE disvariant.
START-OF-SELECTION.
PERFORM material_pass.
PERFORM data_retrieval.
END-OF-SELECTION.
PERFORM sub_display_report.
FORM sub_display_report .
DATA status(1).
IF r1 = 'X'.
PERFORM build_fieldcatalog USING :
'1' 'ERDAT' 'S.O DATE' '' '10' 'X',
'2' 'VBELN' 'SALE ORDER' '' '10' 'X',
'3' 'POSNR' 'SALE ITEM' '' '6' '',
'4' 'BSTKD' 'CUSTOMER PO' '' '35' '',
'5' 'BEZEI' 'REASON FOR REJECTION' '' '40' '',
'6' 'PLNUM' 'PLANNED ORDER' '' '10' '',
'7' 'AUFNR' 'PROD.ORDER.' '' '12' '',
'8' 'MATNR' 'MATERIAL NUMBER' '' '18' '',
'9' 'MAKTX' 'MATERIAL DESCRIPTION' '' '40' '',
'10' 'WERKS' 'PLANT' '' '4' '',
'11' 'KWMENG' 'SALE ORDER QTY' '' '15' '',
'12' 'VRKME' 'UNIT' '' '4' '',
'13' 'GAMNG' 'PROD.ORDER QTY' '' '13' '',
'14' 'IGMNG' 'CONFIRMED ORDER QTY' '' '13' '',
'15' 'GMEIN' 'UNIT' '' '4' '',
'16' 'MENGE' 'G.R QUANTITY' '' '13' '',
'17' 'SOBAL' 'S.O BALANCE' '' '13' '',
'18' 'PRDBAL' 'PROD.BALANCE' '' '13' '',
'19' 'GSM' 'GSM' '' '4' '',
'20' 'SIZE1' 'SIZE1' '' '10' '',
'21' 'SIZE2' 'SIZE2' '' '10' ''.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = pathname
filetype = ftype
append = 'X'
write_field_separator = 'X'
TABLES
data_tab = it_mains
EXCEPTIONS
file_write_error = 1.
IF sy-subrc = 0.
status = 'S'.
ELSE.
status = 'E'.
ENDIF.
ELSEIF r2 = 'X' OR r3 = 'X'.
PERFORM build_fieldcatalog USING :
'1' 'ERDAT' 'S.O DATE' '' '10' 'X',
'2' 'VBELN' 'SALE ORDER' '' '10' 'X',
'3' 'POSNR' 'SALE ITEM' '' '6' '',
'4' 'BSTKD' 'CUSTOMER PO' '' '35' '',
'5' 'BEZEI' 'REASON FOR REJECTION' '' '40' '',
'6' 'PLNUM' 'PLANNED ORDER' '' '10' '',
'7' 'AUFNR' 'PROD.ORDER.' '' '12' '',
'8' 'MATNR' 'MATERIAL NUMBER' '' '18' '',
'9' 'MAKTX' 'MATERIAL DESCRIPTION' '' '40' '',
'10' 'WERKS' 'PLANT' '' '4' '',
'11' 'KWMENG' 'SALE ORDER QTY' '' '15' '',
'12' 'VRKME' 'UNIT' '' '4' '',
'13' 'GAMNG' 'PROD.ORDER QTY' '' '13' '',
'14' 'IGMNG' 'CONFIRMED ORDER QTY' '' '13' '',
'15' 'GMEIN' 'UNIT' '' '4' '',
'16' 'MENGE' 'G.R QUANTITY' '' '13' '',
'17' 'SOBAL' 'S.O BALANCE' '' '13' '',
'18' 'PRDBAL' 'PROD.BALANCE' '' '13' '',
'19' 'GSM' 'GSM' '' '4' '',
'20' 'SIZE1' 'SIZE1' '' '10' '',
'21' 'CUT1' 'CUT1' '' '11' '',
'22' 'SIZE2' 'SIZE2' '' '10' '',
'23' 'CUT2' 'CUT2' '' '11' '',
'24' 'SIZE3' 'SIZE3' '' '10' '',
'25' 'CUT3' 'CUT3' '' '11' '',
'26' 'SIZE4' 'SIZE4' '' '10' '',
'27' 'CUT4' 'CUT4' '' '11' '',
'28' 'SIZE5' 'SIZE5' '' '10' '',
'29' 'CUT5' 'CUT5' '' '11' '',
'30' 'SIZE6' 'SIZE6' '' '10' '',
'31' 'CUT6' 'CUT6' '' '11' ''.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = pathname
filetype = ftype
append = 'X'
write_field_separator = 'X'
TABLES
data_tab = it_mainall
EXCEPTIONS
file_write_error = 1.
IF sy-subrc = 0.
status = 'S'.
ELSE.
status = 'E'.
ENDIF.
ENDIF.
PERFORM build_layout.
PERFORM build_events.
PERFORM sub_comment_build USING it_list_top_of_page.
PERFORM sub_set_variant.
PERFORM display_alv_report.
IF status = 'S'.
MESSAGE 'Excel Output file Downloaded to Given Path' TYPE 'I'.
ELSE.
MESSAGE 'Download Not Possible' TYPE 'I'.
ENDIF.
ENDFORM. " SUB_DISPLAY_REPORT
FORM BUILD_FIELDCATALOG
FORM build_fieldcatalog USING p_col_pos
p_fieldname
p_text
p_datatype
p_outputlen
p_col_freez.
wa_fcat-row_pos = '1'.
wa_fcat-col_pos = p_col_pos.
wa_fcat-fieldname = p_fieldname.
wa_fcat-tabname = c_tabname.
wa_fcat-reptext_ddic = p_text.
wa_fcat-datatype = p_datatype.
wa_fcat-ddic_outputlen = p_outputlen.
wa_fcat-key = p_col_freez.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
FORM build_layout.
CLEAR: wa_layout.
wa_layout-window_titlebar = 'LIST OF GSM WISE OPEN SALE ORDERS'.
wa_layout-colwidth_optimize = 'X'.
wa_layout-totals_text = 'CUMULATIVE'.
ENDFORM. "BUILD_LAYOUT
*& Form BUILD_EVENTS
FORM build_events.
CLEAR wa_event.
REFRESH it_events.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = it_events
EXCEPTIONS
list_type_wrong = 1
OTHERS = 2.
IF sy-subrc = 0.
READ TABLE it_events INTO wa_event
WITH KEY name = 'TOP_OF_PAGE'.
IF sy-subrc EQ 0.
wa_event-form = 'TOP_OF_PAGE'.
APPEND wa_event TO it_events.
CLEAR wa_event.
ENDIF.
ENDIF.
ENDFORM. "BUILD_EVENTS
-->P_IT_LIST_TOP_OF_PAGE text
FORM sub_comment_build USING it_top_of_page TYPE slis_t_listheader.
DATA ls_line TYPE slis_listheader.
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = str1.
APPEND ls_line TO it_top_of_page.
CLEAR ls_line.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header[].
ENDFORM. " SUB_COMMENT_BUILD
*& Form SUB_SET_VARIANT
text
--> p1 text
<-- p2 text
FORM sub_set_variant .
CLEAR wa_variant.
wa_variant-report = sy-repid.
wa_variant-username = sy-uname.
wa_variant-variant = c_variant.
wa_variant-variant = p_layout.
ENDFORM. " SUB_SET_VARIANT
*& Form DISPLAY_ALV_REPORT
*Display Report Using ALV GRID
FORM display_alv_report.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_buffer_active = 'X'
i_callback_program = sy-repid
i_callback_pf_status_set = c_pf_status
i_callback_user_command = c_user_command
is_layout = wa_layout
it_fieldcat = it_fcat
it_sort = it_sort[]
it_events = it_events
i_save = 'A'
is_variant = wa_variant
TABLES
t_outtab = it_main
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE text-204 " 'Error in Display the list'
TYPE 'I'.
LEAVE TO LIST-PROCESSING.
ENDIF.
ENDFORM. . "DISPLAY_ALV_REPORT
*ALV Report Header
FORM top_of_page.
DATA : t_header TYPE slis_t_listheader WITH HEADER LINE,
wa_header TYPE slis_listheader,
t_line LIKE wa_header-info,
ld_lines TYPE i,
ld_linesc(10) TYPE c.
wa_header-typ = 'H'.
T_HEADER-INFO = 'LIST OF GSM WISE OPEN SALE ORDERS'.
wa_header-info = str1.
APPEND wa_header TO t_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header[].
ENDFORM. "TOP_OF_PAGE
here it_main internal table having all data. but output is showing few records only.
pl. give some idea.
Thanks & Regards
Srinivas. -
Regarding reading multiple records into a single internal table..
hi experts,
Need your help, i have a requirement like this.
i will have a input file like this
D 123 Suresh 12/01/2008
E ven sha 5432
E ven sha 5432
D 153 Sachin 11/01/2008
E ven sha 5432
Now all i need to consider from D to E (i.e., before next D) as a single record and i need to preare a separate excel,
So that E records can be max 9. So we cant expect this will be always 2 or 3 or 4.
So how can i do this upload and process..
give some idea.
Thanks,
SureshHi,
Once you transfer the values from input file to internal table.
loop through all records of internal table .
check the first letter using offset
e.g if Itab-field+0(1) = 'D'
elseif Itab-field+0(1) = 'E'.
endif.
Populate the work area of internal table until you find the next 'D' once you find 'D' again ...append the work area to internal table......clear work area.
Regards,
Rahul -
How to append row in internal table for perticular condition
Hi,
I have 4 records in my internal table and i want to append row
after second row when condition will match.
please guide me.
thanks in advancs
regards
SNDhi,
using key word INDEX u can insert a record in aspecified position as
if internal table is with header line.
INSERT <internaltable> index SY_INDEX [or index no if u know where to insert]
with out header line.
INSERT <internaltable> FROM <workarea> index SY_INDEX [or index no if u know where to insert]
if condition is true.
insert itab index 2.
endif.
if helpful reward some points.
with regards,
Suresh.A -
How to extract cost centers and their number of appendant assets to internal table?
Hello,
my aim is to get an internal table with all my selected cost centers and the number of their appendant assets to pass this to a SmartForm.
The result would be something like:
cost center
number of assets
100000
65
100001
13
100002
105
100007
3
100008
57
What I did so far: I made up an SQL statement, which I tested in the transaction DBACOCKPIT (Performance -> Additional Functions -> SQL Command Editor), which works fine and gives me exactly what I need.
The SQL statement is (slightly simplified, and exemplarily only for costcenters 100000 and 100001):
select costcenter, count( assetnr ) as numberofassets from
( select anlz.kostlv as costcenter, anla.anln1 as assetnr, anla.deakt, anla.aktiv from anla
join anlz on anla.mandt = anlz.mandt and anla.bukrs = anlz.bukrs and anla.anln1 = anlz.anln1
where anlz.kostlv = '0000100000' or anlz.kostlv = '00000100001' )
group by costcenter
Now, I want this SQL statement to work in my ABAP code. To match the requirements of the ABAP Editor (SE80), I
- replaced all the point delimiters (.) by a tilde (~),
- removed all commas,
- added "into costcenter_assetcount" to store my result in an internal table.
So in my ABAP code the SQL looks like this (alias assetnr inb the first line is printed in red):
select costcenter count( assetnr ) as numberofassets from
( select anlz~kostlv as costcenter anla~anln1 as assetnr anla~deakt anla~aktiv from anla
join anlz
on anla~mandt = anlz~mandt
and anla~bukrs = anlz~bukrs
and anla~anln1 = anlz~anln1
where anlz~kostlv = '0000100000' or anlz~kostlv = '00000100001' )
into costcenter_assetcount
group by costcenter
Checking my code, ABAP Editor gives me a syntax error pointing to the SELECT of the subquery (it's in German, because this is my default language setting). After my first FROM, ABAP seems to expect a table name instead of a subquery.
Programm Z_FIAA_ASSETCOUNT @0A\QFehler@
"SELECT" ist im ABAP-Dictionary nicht als Tabelle, Projektions- oder
Datenbank-View deklariert.
Isn't it possible to use a SELECT subquery after my FROM in the ABAP Editor?
What would be the best practice to put the data in an internal table?
Looking forward to your comments!Hi,
I think, You make it to complicated, try this:
select anlz~kostlv as costcenter count( distinct anla~anln1 ) as numberofassets
from anla
join anlz
on anla~mandt = anlz~mandt
and anla~bukrs = anlz~bukrs
and anla~anln1 = anlz~anln1
where anlz~kostlv = '0000100000' or anlz~kostlv = '00000100001'
group by anlz~kostlv.
Jarek -
Insert multiple records into database through internal table
Hi
please help me how to insert multiple records into database through internal tableHi,
Welcome to SCN.
Press F1 on INSERT statement and you will teh syntax as well the docu for the same. -
BAPI for updating records in usobt_c from internal table
Can anyone help in implementing this functionality or suggest me which BAPI to use.
Can anyone help in implementing this functionality or suggest me which BAPI to use.
-
How to append records between two internal tables
hi all,
im trying to append from an internal table to another internal table with same structure. i tried the following but it overwrites previous contents of i_dest:
move i_src to i_dest
thanks,
sidhey u try to move it record by record
<b>itab2 = itab.
append itab2.</b>
This should work I guess
just check the code below, if u want to move the whole itab into itab2 then use <b>itab2[] = itab.</b>
<b>loop at it_pgm.
read table itab with key obj_name = it_pgm-pgm_name.
if sy-subrc = 0.
itab_final-obj_name = itab-obj_name.
itab_final-func_spec = itab-func_spec.
itab_final-func_area = itab-func_area.
itab_final-dev_class = itab-dev_class.
append itab_final.
else.
itab_alt-pgm_name = it_pgm-pgm_name.
append itab_alt.
endif.</b>
please reward points if found helpful -
Identifying the maximum length of a record in internal table
Hi,
Im using an internal table for a string for some requirement.
Now, at later point of time i need to use for CHAR variable to copy the data from the above internal table.
I need to identify the max length of the record stored in this internal table so that i can assign that much length to this CHAR variable.
Is there any standard fm or any abap stmts.
Thanks
rohithYou have to Loop the entire Itab to find the Maximum length of the record stored.
Just like this:
data: begin of itab occurs 0,
v_str1 type string,
end of itab.
data: v_len type i.
data: v_len1 type i.
itab-v_str1 = 'mahesh sap abap'.
append itab. clear itab.
itab-v_str1 = 'mahesh'.
append itab. clear itab.
itab-v_str1 = 'mahesh sap'.
append itab. clear itab.
loop at itab.
v_len = strlen( itab-v_str1 ).
if v_len > v_len1.
v_len1 = v_len.
else.
continue.
endif.
clear: v_len.
endloop.
write:/ 'Max Length', v_len1.
Maybe you are looking for
-
How to do JAAS and J2EE Deployment Descriptor ACL : Please help
I am trying to develop a Single sign on application using EJB's, JAAS, ACL, struts and JSP to Log in with a form authenticate (using j_security_check to hook into the web.xml security) then pull a user from a database and use the roles defined there
-
i am recieving an error message that says : "Error 1506: This action is valid for products that are currently installed" and i can't reinstall itunes.... can anyone help me? please! thanks in advance
-
Hi- I need to modify the PZ02 service. I know this service is HR related and several of those do not exist as actual Internet Services (viewable in SE80). They are generated dynamically. <b>How do i modify them?</b> I need to able to view HTML Templ
-
Why will Apple notes will not sync. with iPod or iPad
Why will Apple notes not sysc with iPod or IPad from Mountain Lion?
-
Check in BADI when updating Business Partner
Hi. This question is regarding in general how to know which tables, classes etc. that you are able to use when you are in a BADI. I guess this BADI should be used: BUPA_IDENT_UPDATE, or it might be PARTNER_UPDATE. I need to check if ID_TYPE when Upda