1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 | *&---------------------------------------------------------------------* *& Report ZHM_ISSUANCE *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT ZHM_ISSUANCE. tables: zissuance, vbrk. data: it_vbrk type table of vbrk, gt_zissuance type table of zissuance, ls_zissuance type zissuance, gt_zissuance_cnst type sorted table of zissuance_cnst with unique key constname, it_t005 type sorted table of t005 with unique key land1, it_t005t type sorted table of t005t with unique key land1 spras, it_tvko type sorted table of tvko with unique key vkorg, it_tvbur type sorted table of tvbur with unique key vkbur, it_adrc type sorted table of adrc with unique key addrnumber, it_adrv type sorted table of adrv with non-unique key appl_key, it_kna1 type sorted table of kna1 with unique key kunnr, it_vbrp type sorted table of vbrp with non-unique key vbeln, gt_vbrp type standard table of vbrp, lt_vbrp type standard table of vbrp, it_equi type table of equi, it_konv type table of konv, ls_vbrp type vbrp, ra_fkart type range of fkart, ls_fkart like line of ra_fkart, appl_key type ad_applkey, it_tlines type table of tline. data: bstkd type bstkd, bstdk type bstdk, zconstname type zconstname, zvalue type zvalue, initial_folder type string, selected_folder type string, lifex type lifex, lifexblank type lifex, wadat_ist type wadat_ist, matnr type matnr, uecha type vbrp-uecha, normt type mara-normt, msbookpartno type mara-msbookpartno, vbeln type vbeln, tdname type thead-tdname, kzwi1 type vbrp-kzwi1, lf_adrnr TYPE adrnr, end type i, first type i, i type i, vbelv type vbfa-vbelv, fkart type vbrk-fkart, ffact type tcurf-ffact, tfact type tcurf-tfact, gdatu type tcurf-gdatu, vbtyp_v type vbfa-vbtyp_v, waers type t500c-waers, valid_begda type p0008-begda, valid_endda type p0008-endda, return type sy-subrc, currency_source type dd02l-tabname. data: cl_issuance type ref to zcl_issuance. field-symbols: <fs_vbrk> type vbrk, <fs_vbrp> type vbrp, <fs_zissuance> type zissuance, <fs_zissuance_cnst> type zissuance_cnst, <fs_t005> type t005, <fs_t005t> type t005t, <fs_tvko> type tvko, <fs_tvbur> type tvbur, <fs_adrc> type adrc, <fs_adrv> type adrv, <fs_kna1> type kna1, <fs_konv> type konv, <fs_tlines> type tline, <fs_equi> type equi. select-options: so_vbeln for vbrk-vbeln obligatory, so_fkdat for vbrk-fkdat. create object cl_issuance. select single waers into waers from t001 where bukrs = '1000'. select * from zissuance_cnst into table gt_zissuance_cnst. select * from t005 into table it_t005. select * from t005t into table it_t005t. select * from tvko into table it_tvko. select * from tvbur into table it_tvbur. select * from adrc into table it_adrc. select * from adrv into table it_adrv where appl_table = 'VBUK' and appl_field = 'VBELN' and addr_group = 'SD01'. select * from vbrk into table it_vbrk where vbeln in so_vbeln and fkdat in so_fkdat. "and ( vbrk~rfbsk = 'С' or vbrk~rfbsk = 'E' ). *select * from vbrp into table it_vbrp where vbeln in so_vbeln. select * from kna1 into table it_kna1. loop at gt_zissuance_cnst assigning <fs_zissuance_cnst> where constname(3) = 'DT_'. ls_fkart-sign = 'I'. "I = include, E = exclude ls_fkart-option = 'EQ'. "EQ, BT, NE .... ls_fkart-low = <fs_zissuance_cnst>-constname+3(4). append ls_fkart to ra_fkart. endloop. delete it_vbrk where fkart not in ra_fkart. loop at it_vbrk assigning <fs_vbrk>. clear: matnr, msbookpartno, normt, lifex,wadat_ist,vbeln,vbtyp_v,bstkd,bstdk. append initial line to gt_zissuance assigning <fs_zissuance>. *-->>Номер счет-фактуры унп-год-vbeln <fs_zissuance>-vbeln = <fs_vbrk>-vbeln. *{ INSERT EGPK900161 23 * Тип счет-фактуры <fs_zissuance>-fkart = <fs_vbrk>-fkart. *} INSERT select single paval into <fs_zissuance>-sender from t001z where bukrs = <fs_vbrk>-bukrs and party = 'SAPB01'. concatenate <fs_zissuance>-sender sy-datum(4) <fs_vbrk>-vbeln into <fs_zissuance>-znumber separated by '-'. <fs_zissuance>-datetr = <fs_vbrk>-fkdat. *-->>Выбор типа документа в зависимости от вида фактуры concatenate 'DT_' <fs_vbrk>-fkart into zconstname. read table gt_zissuance_cnst assigning <fs_zissuance_cnst> with table key constname = zconstname. if <fs_zissuance_cnst> is assigned. <fs_zissuance>-doctype = <fs_zissuance_cnst>-value1. unassign <fs_zissuance_cnst>. clear: zconstname, zvalue. endif. *-->>Выбор статуса поставщика из параметров concatenate 'PS_' <fs_vbrk>-fkart into zconstname. read table gt_zissuance_cnst assigning <fs_zissuance_cnst> with table key constname = zconstname. if <fs_zissuance_cnst> is assigned. <fs_zissuance>-provstat = <fs_zissuance_cnst>-value1. unassign <fs_zissuance_cnst>. clear: zconstname, zvalue. else. concatenate 'STORNO_' <fs_vbrk>-fkart into zconstname. read table gt_zissuance_cnst assigning <fs_zissuance_cnst> with table key constname = zconstname. if <fs_zissuance_cnst> is assigned. <fs_zissuance>-provstat = <fs_zissuance_cnst>-value1. select single vbelv into vbelv from vbfa where vbeln = <fs_vbrk>-vbeln and vbtyp_v = 'P'. select single fkart into fkart from vbrk where vbeln = <fs_vbrk>-vbeln. unassign <fs_zissuance_cnst>. concatenate 'PS_' fkart into zconstname. read table gt_zissuance_cnst assigning <fs_zissuance_cnst> with table key constname = zconstname. if <fs_zissuance_cnst> is assigned. <fs_zissuance>-provstat = <fs_zissuance_cnst>-value1. unassign <fs_zissuance_cnst>. clear: zconstname, zvalue. endif. clear: zconstname, zvalue. endif. endif. *-->>Выбор кода страны read table it_t005 assigning <fs_t005> with table key land1 = <fs_vbrk>-landtx. if <fs_t005> is assigned. <fs_zissuance>-provcountrycode = <fs_t005>-intcn3. unassign <fs_t005>. endif. *-->>УНП поставщика <fs_zissuance>-provunp = <fs_zissuance>-sender. *-->>Наименование поставщика*{ DELETE EGPK900161 19 read table it_tvko assigning <fs_tvko> with table key vkorg = <fs_vbrk>-vkorg. if <fs_tvko> is assigned. read table it_adrc assigning <fs_adrc> with table key addrnumber = <fs_tvko>-adrnr. if <fs_adrc> is assigned. concatenate <fs_adrc>-name1 <fs_adrc>-name2 <fs_adrc>-name3 <fs_adrc>-name4 into <fs_zissuance>-provname separated by space. *Адрес поставщика и грузоотправителя, адрес грузоотправителя может быть заменен на пункт выгрузки далее concatenate <fs_adrc>-post_code1 <fs_adrc>-city1 <fs_adrc>-street <fs_adrc>-house_num1 into <fs_zissuance>-provaddress separated by ','. * <fs_zissuance>-consaddress = <fs_zissuance>-provaddress. unassign <fs_adrc>. endif. unassign <fs_tvko>. endif. *-->>Выбор статуса получателя из параметров *-->>Выбор статуса поставщика из параметров concatenate 'RS_' <fs_vbrk>-fkart into zconstname. read table gt_zissuance_cnst assigning <fs_zissuance_cnst> with table key constname = zconstname. if <fs_zissuance_cnst> is assigned. <fs_zissuance>-recstat = <fs_zissuance_cnst>-value1. unassign <fs_zissuance_cnst>. clear: zconstname, zvalue. else. concatenate 'STORNO_' <fs_vbrk>-fkart into zconstname. read table gt_zissuance_cnst assigning <fs_zissuance_cnst> with table key constname = zconstname. if <fs_zissuance_cnst> is assigned. <fs_zissuance>-recstat = <fs_zissuance_cnst>-value1. select single vbelv into vbelv from vbfa where vbeln = <fs_vbrk>-vbeln and vbtyp_v = 'P'. select single fkart into fkart from vbrk where vbeln = <fs_vbrk>-vbeln. unassign <fs_zissuance_cnst>. concatenate 'RS_' fkart into zconstname. read table gt_zissuance_cnst assigning <fs_zissuance_cnst> with table key constname = zconstname. if <fs_zissuance_cnst> is assigned. <fs_zissuance>-recstat = <fs_zissuance_cnst>-value1. unassign <fs_zissuance_cnst>. clear: zconstname, zvalue. endif. clear: zconstname, zvalue. endif. endif. *-->>Взаимозависимое лицо <fs_zissuance>-recdeppers = ''. <fs_zissuance>-provdeppers = ''. *-->>Сделка с резидентом оффшорной зоны <fs_zissuance>-recoffshore = ''. <fs_zissuance>-provoffshore = ''. *-->>Сделка с товарами по перечню, определяемому правительством <fs_zissuance>-recspecgoods = ''. <fs_zissuance>-provspecgoods = ''. *-->>Организация в перечне крупных плательщиков <fs_zissuance>-recbigcomp = ''. <fs_zissuance>-provbigcomp = 'X'. *-->>Выбор кода страны read table it_kna1 assigning <fs_kna1> with table key kunnr = <fs_vbrk>-kunag. if <fs_kna1> is assigned. read table it_t005 assigning <fs_t005> with table key land1 = <fs_kna1>-land1. if <fs_t005> is assigned. <fs_zissuance>-reccountrycode = <fs_t005>-intcn3. read table it_t005t assigning <fs_t005t> with table key land1 = <fs_kna1>-land1 spras = sy-langu. concatenate <fs_t005t>-landx <fs_kna1>-ort01 <fs_kna1>-pstlz <fs_kna1>-stras into <fs_zissuance>-recaddress separated by space. unassign: <fs_t005>, <fs_t005t>. endif. *-->>УНП получателя <fs_zissuance>-recunp = <fs_kna1>-stcd1. *-->>Наименование получателя concatenate <fs_kna1>-name2 <fs_kna1>-name3 <fs_kna1>-name4 into <fs_zissuance>-recname separated by space. unassign <fs_kna1>. endif. *-->>Наименование получателя Получателям (и Грузполучателям) –физлицам - *CRL. if <fs_vbrk>-kunag cp 'FL*CRL76' or <fs_vbrk>-kunag cp 'FL*CRL' or <fs_vbrk>-kunag cp 'FIZ*CRL'. concatenate sy-mandt <fs_vbrk>-vbeln into appl_key. read table it_adrv assigning <fs_adrv> with table key appl_key = appl_key. if <fs_adrv> is assigned. read table it_adrc assigning <fs_adrc> with table key addrnumber = <fs_adrv>-addrnumber. if <fs_adrc> is assigned. <fs_zissuance>-recname = <fs_adrc>-name2. endif. endif. unassign: <fs_adrv>, <fs_adrc>. endif. select single bstkd bstdk into (bstkd,bstdk) from vbfa inner join vbkd on vbfa~vbelv = vbkd~vbeln where vbfa~vbtyp_v = 'C' and vbfa~vbeln = <fs_vbrk>-vbeln. select single likp~lifex likp~wadat_ist likp~vbeln vbfa~vbtyp_v into (lifex,wadat_ist,vbeln,vbtyp_v) from vbfa inner join likp on vbfa~vbelv = likp~vbeln where vbfa~vbeln = <fs_vbrk>-vbeln and ( vbfa~vbtyp_n = 'M' or vbfa~vbtyp_n = 'P' or vbfa~vbtyp_n = 'O' or vbfa~vbtyp_n = 'N' or vbfa~vbtyp_n = 'S' ). *Дата и номер договора из заголовка фактуры if bstkd is initial or bstdk is initial. tdname = vbeln. call function 'READ_TEXT' exporting client = sy-mandt id = 'Z005' language = sy-langu name = tdname object = 'VBBK' tables lines = it_tlines exceptions id = 1 language = 2 name = 3 not_found = 4 object = 5 reference_check = 6 wrong_access_to_archive = 7. if sy-subrc = 0. data: moff TYPE i, mlen TYPE i, datcont(10) type c, offset type i, string type string. loop at it_tlines assigning <fs_tlines>. find first occurrence of regex '[0-2]?[0-9].[0-1][0-9].[2][0-3][0-9][0-9]' in <fs_tlines>-tdline match offset moff match length mlen. if sy-subrc = 0. offset = moff + mlen. <fs_tlines>-tdline = <fs_tlines>-tdline+0(offset). datcont = <fs_tlines>-tdline+moff(mlen). find first occurrence of '.' in datcont match offset moff match length mlen. offset = 4 + moff. <fs_zissuance>-contractdata(4) = datcont+offset(4). offset = 1 + moff. <fs_zissuance>-contractdata+4(2) = datcont+offset(2). <fs_zissuance>-contractdata+6(2) = datcont(offset). replace datcont with '' into <fs_tlines>-tdline. replace 'ОТ' with '' into <fs_tlines>-tdline. <fs_zissuance>-contractnumber = <fs_tlines>-tdline. else. find first occurrence of regex '[0-2]?[0-9].[0-1][0-9].[0-9][0-9]' in <fs_tlines>-tdline match offset moff match length mlen. if sy-subrc = 0. offset = moff + mlen. <fs_tlines>-tdline = <fs_tlines>-tdline+0(offset). datcont = <fs_tlines>-tdline+moff(mlen). find first occurrence of '.' in datcont match offset moff match length mlen. offset = 4 + moff. <fs_zissuance>-contractdata(2) = '20'. <fs_zissuance>-contractdata+2(2) = datcont+offset(2). offset = 1 + moff. <fs_zissuance>-contractdata+4(2) = datcont+offset(2). <fs_zissuance>-contractdata+6(2) = datcont(offset). replace datcont with '' into <fs_tlines>-tdline. replace 'ОТ' with '' into <fs_tlines>-tdline. replace 'от' with '' into <fs_tlines>-tdline. string = <fs_tlines>-tdline. find first occurrence of regex '[0-9]' in <fs_tlines>-tdline match offset moff match length mlen. * perform find_digits using string. * condense string. if sy-subrc = 0. offset = strlen( <fs_tlines>-tdline ) - moff . <fs_zissuance>-contractnumber = <fs_tlines>-tdline+moff(offset). else. <fs_zissuance>-contractnumber = <fs_tlines>-tdline. endif. endif. endif. endloop. endif. endif. lifexblank = lifex. condense lifexblank. lifexblank+2(1) = '0'. translate lifexblank to upper case. condense lifex no-gaps. translate lifex to upper case. if bstkd is not initial. <fs_zissuance>-contractnumber = bstkd. endif. if bstdk is not initial. <fs_zissuance>-contractdata = bstdk. endif. <fs_zissuance>-contractdocdata = wadat_ist . <fs_zissuance>-contractblseria = lifex(2). <fs_zissuance>-contractblnumber = lifex+2. *Вид документа и код бланка if vbtyp_v = 'J' or vbtyp_v = 'T'. select * into corresponding fields of table it_equi from equi where equi~sernr = lifexblank. sort it_equi by erdat descending. read table it_equi index 1 assigning <fs_equi>. if <fs_equi> is assigned. matnr = <fs_equi>-matnr. select single msbookpartno normt into (msbookpartno,normt) from mara where matnr = matnr. if sy-subrc = 0. <fs_zissuance>-contractdoct = msbookpartno. <fs_zissuance>-contractblcode = normt. else. clear: msbookpartno, normt, matnr. endif. unassign <fs_equi>. else. clear: matnr. endif. else. select single vbfa~vbtyp_v into vbtyp_v from vbfa where vbfa~vbeln = <fs_vbrk>-vbeln and ( vbfa~vbtyp_v = 'C' or vbfa~vbtyp_v = 'J' ) and vbfa~vbtyp_n = 'M'. if sy-subrc = 0. <fs_zissuance>-contractdoct = '608'. <fs_zissuance>-contractblcode = ''. if <fs_zissuance>-contractnumber is initial. <fs_zissuance>-contractnumber = <fs_vbrk>-vbeln. endif. if <fs_zissuance>-contractdata is initial. <fs_zissuance>-contractdata = <fs_vbrk>-fkdat. endif. <fs_zissuance>-contractdocdata = <fs_vbrk>-fkdat. <fs_zissuance>-contractblnumber = <fs_vbrk>-vbeln. clear: <fs_zissuance>-cogneaddress, <fs_zissuance>-consaddress. endif. endif. if <fs_zissuance>-contractdoct is initial or vbtyp_v = 'T'. <fs_zissuance>-contractdoct = '601'. endif. *Пункт выгрузки if <fs_zissuance>-contractdoct = '608'. else. tdname = vbeln. * Пункта отправления if <fs_zissuance>-contractdoct = '603'. perform read_text using 'Z030' tdname 'VBBK' changing <fs_zissuance>-consaddress. perform read_text using 'Z031' vbeln 'VBBK' changing <fs_zissuance>-cogneaddress. endif. * Адрес погрузки, если не заполнен из текста z030 if <fs_zissuance>-consaddress is initial. read table it_tvko assigning <fs_tvko> with table key vkorg = <fs_vbrk>-vkorg. if <fs_tvko> is assigned. read table it_adrc assigning <fs_adrc> with table key addrnumber = <fs_tvko>-adrnr. if <fs_adrc> is assigned. concatenate <fs_adrc>-city1 <fs_adrc>-street <fs_adrc>-house_num1 into <fs_zissuance>-consaddress separated by ', '. endif. endif. endif. * Пункт назначения если не заполнен из текста z031 if <fs_zissuance>-cogneaddress is initial. select single adrnr from vbpa into lf_adrnr where vbeln eq <fs_vbrk>-vbeln and parvw EQ 'WE'. if sy-subrc = 0. read table it_adrc assigning <fs_adrc> with table key addrnumber = lf_adrnr. if <fs_adrc> is assigned. concatenate <fs_adrc>-city1 <fs_adrc>-street <fs_adrc>-house_num1 into <fs_zissuance>-cogneaddress separated by ', '. endif. endif. endif. endif. select * from vbrp appending corresponding fields of table it_vbrp where vbeln = <fs_vbrk>-vbeln. clear: <fs_zissuance>-totalvat. select * from konv into table it_konv where knumv = <fs_vbrk>-knumv. gdatu = 99999999 - <fs_vbrk>-fkdat. select single ffact tfact into (ffact,tfact) from tcurf where tcurr = waers and fcurr = <fs_vbrk>-waerk and kurst = 'M' and gdatu <= gdatu. if sy-subrc <> 0. ffact = 1. tfact = 1. endif. loop at it_vbrp assigning <fs_vbrp> where vbeln = <fs_vbrk>-vbeln. select single max( stawn ) into <fs_vbrp>-ean11 from marc where matnr = <fs_vbrp>-matnr. "код ТН ВЭД <fs_zissuance>-totalvat = <fs_zissuance>-totalvat + <fs_vbrp>-kzwi5 * <fs_vbrk>-kurrf * tfact / ffact. if <fs_vbrk>-fkart = 'ZF6' or <fs_vbrk>-fkart = 'ZF7'. read table it_konv assigning <fs_konv> with key kposn = <fs_vbrp>-posnr kschl = 'ZPRM' kinak = ''. if <fs_konv> is assigned. <fs_vbrp>-netwr = <fs_konv>-kwert. unassign <fs_konv>. endif. read table it_konv assigning <fs_konv> with key kschl = 'ZND1' kposn = <fs_vbrp>-posnr. if <fs_konv> is assigned. <fs_vbrp>-kzwi1 = <fs_konv>-kbetr / 10. unassign <fs_konv>. endif. else. read table it_konv assigning <fs_konv> with key kschl = 'ZWB1' kposn = <fs_vbrp>-posnr. if <fs_konv> is assigned. <fs_vbrp>-kzwi1 = <fs_konv>-kbetr / 10. unassign <fs_konv>. endif. endif. <fs_vbrp>-volum = ffact / tfact. <fs_vbrp>-kursk = <fs_vbrk>-kurrf. append <fs_vbrp> to gt_vbrp. endloop. if <fs_vbrk>-fkart = 'ZF6' or <fs_vbrk>-fkart = 'ZF7'. <fs_zissuance>-totalcostvat = <fs_vbrk>-netwr * <fs_vbrk>-kurrf * tfact / ffact. <fs_zissuance>-totalcost = <fs_zissuance>-totalcostvat - <fs_zissuance>-totalvat. else. <fs_zissuance>-totalcost = <fs_vbrk>-netwr * <fs_vbrk>-kurrf * tfact / ffact. <fs_zissuance>-totalcostvat = <fs_zissuance>-totalvat + <fs_zissuance>-totalcost. endif. unassign: <fs_zissuance>. endloop. delete from zissuance. clear: it_vbrk, it_t005, it_t005t, it_tvko, it_tvbur, it_adrc, it_kna1, it_vbrp. insert zissuance from table gt_zissuance accepting duplicate keys. update zissuance from table gt_zissuance. modify zissuance from table gt_zissuance. *-->>Выбор начальной папки из параметров concatenate 'INITIAL' '_FOLDER' into zconstname. read table gt_zissuance_cnst assigning <fs_zissuance_cnst> with table key constname = zconstname. if <fs_zissuance_cnst> is assigned. initial_folder = <fs_zissuance_cnst>-value1. unassign <fs_zissuance_cnst>. clear: zconstname, zvalue. endif. call method cl_gui_frontend_services=>directory_browse exporting initial_folder = initial_folder window_title = 'Каталог выгрузки счетов' changing selected_folder = selected_folder exceptions cntl_error = 1 error_no_gui = 2 not_supported_by_gui = 3 others = 4. if sy-subrc <> 0. message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. elseif selected_folder is initial. leave screen. endif. loop at gt_zissuance assigning <fs_zissuance>. clear i. i = 1. clear: end, lt_vbrp, first. sort gt_vbrp by matnr uecha. loop at gt_vbrp assigning <fs_vbrp> where vbeln = <fs_zissuance>-vbeln. if <fs_vbrp>-uecha > 0. else. <fs_vbrp>-uecha = <fs_vbrp>-posnr. endif. end = end + 1. endloop. loop at gt_vbrp assigning <fs_vbrp> where vbeln = <fs_zissuance>-vbeln. end = end - 1. if first = 0. first = 1. ls_vbrp = <fs_vbrp>. i = 1. ls_vbrp-fklmg = 0. ls_vbrp-netwr = 0. ls_vbrp-kzwi5 = 0. ls_vbrp-kzwi4 = 0. ls_vbrp-uepos = i. matnr = <fs_vbrp>-matnr. uecha = <fs_vbrp>-uecha. kzwi1 = <fs_vbrp>-kzwi1. endif. if matnr = <fs_vbrp>-matnr and uecha = <fs_vbrp>-uecha. if <fs_vbrp>-kzwi1 > kzwi1. ls_vbrp-kzwi1 = <fs_vbrp>-kzwi1. endif. ls_vbrp-fklmg = ls_vbrp-fklmg + <fs_vbrp>-fklmg. ls_vbrp-netwr = ls_vbrp-netwr + <fs_vbrp>-netwr. ls_vbrp-kzwi5 = ls_vbrp-kzwi5 + <fs_vbrp>-kzwi5. ls_vbrp-kzwi4 = ls_vbrp-kzwi4 + <fs_vbrp>-kzwi4. else. append ls_vbrp to lt_vbrp. ls_vbrp = <fs_vbrp>. i = i + 1. ls_vbrp-uepos = i. matnr = <fs_vbrp>-matnr. if <fs_vbrp>-uecha > 0. uecha = <fs_vbrp>-uecha. endif. endif. if end = 0. append ls_vbrp to lt_vbrp. endif. endloop. loop at lt_vbrp assigning <fs_vbrp> where vbeln = <fs_zissuance>-vbeln. if <fs_zissuance>-fkart = 'ZS1' "СторноCчетФактуры or <fs_zissuance>-fkart = 'S2' " Сторно кредит-авизо or <fs_zissuance>-fkart = 'ZRE' "Кредитов. возврата or <fs_zissuance>-fkart = 'ZG2'. "Кредитовое авизо <fs_vbrp>-fklmg = -1 * <fs_vbrp>-fklmg. <fs_vbrp>-netwr = -1 * <fs_vbrp>-netwr. <fs_vbrp>-kzwi5 = -1 * <fs_vbrp>-kzwi5. <fs_vbrp>-kzwi4 = -1 * <fs_vbrp>-kzwi4. endif. endloop. if <fs_zissuance>-fkart = 'ZS1' "СторноCчетФактуры or <fs_zissuance>-fkart = 'S2' " Сторно кредит-авизо or <fs_zissuance>-fkart = 'ZRE' "Кредитов. возврата or <fs_zissuance>-fkart = 'ZG2'. "Кредитовое авизо <fs_zissuance>-totalvat = -1 * <fs_zissuance>-totalvat. <fs_zissuance>-totalcost = -1 * <fs_zissuance>-totalcost. <fs_zissuance>-totalcostvat = -1 * <fs_zissuance>-totalcostvat. endif. sort lt_vbrp by posnr. i = 1. loop at lt_vbrp assigning <fs_vbrp>. <fs_vbrp>-uepos = i. i = i + 1. endloop. cl_issuance->export_xml( exporting patch = selected_folder issuance = <fs_zissuance> vbrp = lt_vbrp ). endloop. form find_digits changing text type string. DATA: text_tab TYPE TABLE OF string, str(5) type c, result_tab TYPE TABLE OF int2 WITH HEADER LINE. split text at space into table text_tab. replace all occurrences of regex: '[ [:punct:] ]' in table text_tab with '', '[ [:alpha:] ]' in table text_tab with '', '[ [:blank:] ]' in table text_tab with '', '[ [:space:] ]' in table text_tab with ''. delete text_tab where table_line is initial. append lines of text_tab to result_tab. clear text. loop at result_tab. str = result_tab. concatenate text str into text. endloop. condense text. endform. *&---------------------------------------------------------------------* *& Form READ_TEXT *&---------------------------------------------------------------------* FORM read_text USING p_id p_tdname p_object CHANGING p_text. * <= 05.10.2015 PIMENOV_SV *" <= 01.10.2015 PIMENOV_SV * TYPES: BEGIN OF t_text, * text(72) TYPE c, * END OF t_text. * DATA: i_textstream TYPE TABLE OF t_text, * w_textstream TYPE t_text. *" => 01.10.2015 PIMENOV_SV " => 05.10.2015 PIMENOV_SV DATA: lt_tline TYPE TABLE OF tline, ls_tline TYPE tline. * lf_tdname type tdobname. DATA: lf_id TYPE tdid, lf_name TYPE tdobname, lf_object TYPE tdobject. lf_id = p_id. lf_name = p_tdname. lf_object = p_object. CALL FUNCTION 'READ_TEXT' EXPORTING client = sy-mandt id = lf_id language = sy-langu name = lf_name object = lf_object TABLES lines = lt_tline EXCEPTIONS id = 1 language = 2 name = 3 not_found = 4 object = 5 reference_check = 6 wrong_access_to_archive = 7 OTHERS = 8. IF sy-subrc EQ 0. * <= 05.10.2015 PIMENOV_SV *" <= 01.10.2015 PIMENOV_SV * CALL FUNCTION 'CONVERT_ITF_TO_STREAM_TEXT' * EXPORTING * language = sy-langu * TABLES * itf_text = lt_tline * text_stream = i_textstream. LOOP AT lt_tline INTO ls_tline. CONCATENATE p_text ls_tline-tdline * LOOP AT i_textstream INTO w_textstream. * CONCATENATE p_text w_textstream-text * => 01.10.2015 PIMENOV_SV INTO p_text SEPARATED BY space. ENDLOOP. CONDENSE p_text. REPLACE ALL OCCURRENCES OF '<(>&<)>' IN p_text WITH '&' IN CHARACTER MODE. * => 05.10.2015 PIMENOV_SV ENDIF. ENDFORM. " READ_TEXT *&---------------------------------------------------------------------* *& Form GET_UNLOADING_POINT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_LF_ADRNR text * <--P_LS_ZTTN1_DATA_UNLOADING text *----------------------------------------------------------------------* FORM get_unloading_point USING iv_adrnr TYPE tvko-adrnr CHANGING value(ev_name) TYPE c. DATA: itab_adrc TYPE adrc, landx TYPE t005t-landx, ev_address_house(30) TYPE c. ** Адреса (центральное управление адресами) SELECT SINGLE city1 street house_num1 house_num2 house_num3 langu FROM adrc INTO CORRESPONDING FIELDS OF itab_adrc WHERE addrnumber = iv_adrnr. IF itab_adrc IS NOT INITIAL. * Строка с бла-бла-и-адресами CONCATENATE itab_adrc-house_num1 itab_adrc-house_num2 itab_adrc-house_num3 INTO ev_address_house SEPARATED BY space. CONCATENATE itab_adrc-city1 itab_adrc-street INTO ev_name SEPARATED BY ', '. CONCATENATE ev_name ev_address_house INTO ev_name SEPARATED BY space. CONDENSE ev_name. ENDIF. ENDFORM. " GET_POS_NAME *} INSERT method EXPORT_XML. * Вывод xml-файла type-pools: ixml. types:begin of xml_line, data(256) type x, end of xml_line. data: l_ixml type ref to if_ixml, l_streamfactory type ref to if_ixml_stream_factory, l_ostream type ref to if_ixml_ostream, l_renderer type ref to if_ixml_renderer, l_document type ref to if_ixml_document, l_xml_table type table of xml_line, l_xml_size type i, l_rc type i. data: l_element_general type ref to if_ixml_element, l_element_issuance type ref to if_ixml_element, l_element_generaltype type ref to if_ixml_element, l_element_number type ref to if_ixml_element, l_element_dateIssuance type ref to if_ixml_element, l_element_dateTransaction type ref to if_ixml_element, l_element_documentType type ref to if_ixml_element, l_element_provider type ref to if_ixml_element, l_element_providerStatus type ref to if_ixml_element, l_element_dependentPerson type ref to if_ixml_element, l_element_residentsOfOffshore type ref to if_ixml_element, l_element_specialDealGoods type ref to if_ixml_element, l_element_bigCompany type ref to if_ixml_element, l_element_countryCode type ref to if_ixml_element, l_element_unp type ref to if_ixml_element, l_element_name type ref to if_ixml_element, l_element_address type ref to if_ixml_element, l_element_taxes type ref to if_ixml_element, l_element_number_t type ref to if_ixml_element, l_element_date type ref to if_ixml_element, l_element_recipient type ref to if_ixml_element, l_element_recipientStatus type ref to if_ixml_element, l_element_dependentPerson1 type ref to if_ixml_element, l_element_residentsOfOffshore1 type ref to if_ixml_element, l_element_specialDealGoods1 type ref to if_ixml_element, l_element_bigCompany1 type ref to if_ixml_element, l_element_countryCode1 type ref to if_ixml_element, l_element_unp1 type ref to if_ixml_element, l_element_name1 type ref to if_ixml_element, l_element_address1 type ref to if_ixml_element, l_element_senderReceiver type ref to if_ixml_element, l_element_consignors type ref to if_ixml_element, l_element_consignor type ref to if_ixml_element, l_element_countruCode2 type ref to if_ixml_element, l_element_unp2 type ref to if_ixml_element, l_element_name2 type ref to if_ixml_element, l_element_address2 type ref to if_ixml_element, l_element_consignees type ref to if_ixml_element, l_element_consignee type ref to if_ixml_element, l_element_countruCode3 type ref to if_ixml_element, l_element_unp3 type ref to if_ixml_element, l_element_name3 type ref to if_ixml_element, l_element_address3 type ref to if_ixml_element, l_element_deliveryCondition type ref to if_ixml_element, l_element_contract type ref to if_ixml_element, l_element_number1 type ref to if_ixml_element, l_element_date1 type ref to if_ixml_element, l_element_documents type ref to if_ixml_element, l_element_document type ref to if_ixml_element, l_element_docType type ref to if_ixml_element, l_element_code type ref to if_ixml_element, l_element_date2 type ref to if_ixml_element, l_element_blankCode type ref to if_ixml_element, l_element_seria type ref to if_ixml_element, l_element_number2 type ref to if_ixml_element, l_element_roster type ref to if_ixml_element, l_element_rosterItem type ref to if_ixml_element, l_element_number3 type ref to if_ixml_element, l_element_name4 type ref to if_ixml_element, l_element_code1 type ref to if_ixml_element, l_element_units type ref to if_ixml_element, l_element_count type ref to if_ixml_element, l_element_price type ref to if_ixml_element, l_element_cost type ref to if_ixml_element, l_element_summaExcise type ref to if_ixml_element, l_element_vat type ref to if_ixml_element, l_element_rate type ref to if_ixml_element, l_element_rateType type ref to if_ixml_element, l_element_summaVat type ref to if_ixml_element, l_element_costVat type ref to if_ixml_element, l_element_descriptions type ref to if_ixml_element, l_element_description type ref to if_ixml_element. data: xmlns type zvalue, sender type zvalue, *{ INSERT EGPK900316 2 str(16) type c, *} INSERT string type string, zconstname type zconstname, zvalue type zvalue, str20(20) type c, it_vbrp type table of vbrp. field-symbols: <fs_vbrp> type vbrp. it_vbrp[] = vbrp[]. * <-----вывод xml-файла me->select_parameter( exporting constname = 'xmlns' importing value = xmlns ). me->select_parameter( exporting constname = 'sender' importing value = sender ). l_ixml = cl_ixml=>create( ). l_document = l_ixml->create_document( ). l_element_issuance = l_document->create_simple_element( name = 'issuance' parent = l_document ). clear string. string = xmlns. translate string to lower case. l_rc = l_element_issuance->set_attribute( name = 'xmlns' value = string ). clear string. string = sender. l_rc = l_element_issuance->set_attribute( name = 'sender' value = string ). * Общий раздел l_element_general = l_document->create_simple_element( name = 'general' parent = l_element_issuance ). clear string. string = issuance-znumber. l_element_number = l_document->create_simple_element( name = 'number' value = string parent = l_element_general ). clear string. * string = sy-datum. concatenate sy-datum(4) '-' sy-datum+4(2) '-' sy-datum+6(2) into string. l_element_dateIssuance = l_document->create_simple_element( name = 'dateIssuance' value = string parent = l_element_general ). clear string. * string = issuance-datetr. concatenate issuance-datetr(4) '-' issuance-datetr+4(2) '-' issuance-datetr+6(2) into string. l_element_dateTransaction = l_document->create_simple_element( name = 'dateTransaction' value = string parent = l_element_general ). clear string. string = issuance-doctype. l_element_documentType = l_document->create_simple_element( name = 'documentType' value = string parent = l_element_general ). * Реквизиты поставщика l_element_provider = l_document->create_simple_element( name = 'provider' parent = l_element_issuance ). clear string. string = issuance-provstat. l_element_providerStatus = l_document->create_simple_element( name = 'providerStatus' value = string parent = l_element_provider ). if issuance-provdeppers = 'X'. string = 'true'. else. string = 'false'. endif. l_element_dependentPerson = l_document->create_simple_element( name = 'dependentPerson' value = string parent = l_element_provider ). if issuance-provoffshore = 'X'. string = 'true'. else. string = 'false'. endif. l_element_residentsOfOffshore = l_document->create_simple_element( name = 'residentsOfOffshore' value = string parent = l_element_provider ). if issuance-provspecgoods = 'X'. string = 'true'. else. string = 'false'. endif. l_element_specialDealGoods = l_document->create_simple_element( name = 'specialDealGoods' value = string parent = l_element_provider ). if issuance-provbigcomp = 'X'. string = 'true'. else. string = 'false'. endif. l_element_bigCompany = l_document->create_simple_element( name = 'bigCompany' value = string parent = l_element_provider ). clear string. string = issuance-provcountrycode. l_element_countryCode = l_document->create_simple_element( name = 'countryCode' value = string parent = l_element_provider ). clear string. string = issuance-provunp. l_element_unp = l_document->create_simple_element( name = 'unp' value = string parent = l_element_provider ). clear string. string = issuance-provname. l_element_name = l_document->create_simple_element( name = 'name' value = string parent = l_element_provider ). clear string. string = issuance-provaddress. l_element_address = l_document->create_simple_element( name = 'address' value = string parent = l_element_provider ). * l_element_taxes = l_document->create_simple_element( name = 'taxes' parent = l_element_provider ). * string = * l_element_number_t = l_document->create_simple_element( name = 'number_t' value = '6317191120150002' parent = l_element_taxes ). * l_element_date = l_document->create_simple_element( name = 'date' value = '2015-11-19' parent = l_element_taxes ). * Реквизиты получателя l_element_recipient = l_document->create_simple_element( name = 'recipient' parent = l_element_issuance ). clear string. string = issuance-recstat. l_element_recipientStatus = l_document->create_simple_element( name = 'recipientStatus' value = string parent = l_element_recipient ). clear string. if issuance-recdeppers = 'X'. string = 'true'. else. string = 'false'. endif. l_element_dependentPerson1 = l_document->create_simple_element( name = 'dependentPerson' value = string parent = l_element_recipient ). clear string. if issuance-recoffshore = 'X'. string = 'true'. else. string = 'false'. endif. l_element_residentsOfOffshore1 = l_document->create_simple_element( name = 'residentsOfOffshore' value = string parent = l_element_recipient ). clear string. if issuance-recspecgoods = 'X'. string = 'true'. else. string = 'false'. endif. l_element_specialDealGoods1 = l_document->create_simple_element( name = 'specialDealGoods' value = string parent = l_element_recipient ). clear string. if issuance-recbigcomp = 'X'. string = 'true'. else. string = 'false'. endif. l_element_bigCompany1 = l_document->create_simple_element( name = 'bigCompany' value = string parent = l_element_recipient ). clear string. string = issuance-reccountrycode. l_element_countryCode1 = l_document->create_simple_element( name = 'countryCode' value = string parent = l_element_recipient ). clear string. string = issuance-recunp. l_element_unp1 = l_document->create_simple_element( name = 'unp' value = string parent = l_element_recipient ). clear string. string = issuance-recname. l_element_name1 = l_document->create_simple_element( name = 'name' value = string parent = l_element_recipient ). clear string. string = issuance-recaddress. l_element_address1 = l_document->create_simple_element( name = 'address' value = string parent = l_element_recipient ). * Реквизиты грузопоотправителя и грузополучателя l_element_senderReceiver = l_document->create_simple_element( name = 'senderReceiver' parent = l_element_issuance ). * Список грузоотправителей l_element_consignors = l_document->create_simple_element( name = 'consignors' parent = l_element_senderReceiver ). *{ REPLACE EGPK900316 10 *\ if issuance-consaddress is not initial. *} REPLACE * Грузоотправитель l_element_consignor = l_document->create_simple_element( name = 'consignor' parent = l_element_consignors ). clear string. string = issuance-provcountrycode. l_element_countruCode2 = l_document->create_simple_element( name = 'countryCode' value = string parent = l_element_consignor ). clear string. string = issuance-provunp. l_element_unp2 = l_document->create_simple_element( name = 'unp' value = string parent = l_element_consignor ). clear string. string = issuance-provname. l_element_name2 = l_document->create_simple_element( name = 'name' value = string parent = l_element_consignor ). clear string. string = issuance-consaddress. l_element_address2 = l_document->create_simple_element( name = 'address' value = string parent = l_element_consignor ). *{ INSERT EGPK900316 9 endif. *} INSERT * Список грузополучателей l_element_consignees = l_document->create_simple_element( name = 'consignees' parent = l_element_senderReceiver ). *{ INSERT EGPK900316 8 if issuance-cogneaddress is not initial. *} INSERT * Грузополучатель l_element_consignee = l_document->create_simple_element( name = 'consignee' parent = l_element_consignees ). clear string. string = issuance-reccountrycode. l_element_countruCode3 = l_document->create_simple_element( name = 'countryCode' value = string parent = l_element_consignee ). clear string. string = issuance-recunp. l_element_unp3 = l_document->create_simple_element( name = 'unp' value = string parent = l_element_consignee ). clear string. string = issuance-recname. l_element_name3 = l_document->create_simple_element( name = 'name' value = string parent = l_element_consignee ). clear string. *{ REPLACE EGPK900316 6 *\ string = issuance-recaddress. string = issuance-cogneaddress. *} REPLACE l_element_address3 = l_document->create_simple_element( name = 'address' value = string parent = l_element_consignee ). *{ INSERT EGPK900316 7 endif. *} INSERT * Условия поставки l_element_deliveryCondition = l_document->create_simple_element( name = 'deliveryCondition' parent = l_element_issuance ). * Договор (контракт) на поставку товаров (выполнения работ, оказания услуг), передачу имущественных прав l_element_contract = l_document->create_simple_element( name = 'contract' parent = l_element_deliveryCondition ). clear string. string = issuance-contractnumber. l_element_number1 = l_document->create_simple_element( name = 'number' value = string parent = l_element_contract ). clear string. string = issuance-contractdata. concatenate issuance-contractdata(4) '-' issuance-contractdata+4(2) '-' issuance-contractdata+6(2) into string. l_element_date1 = l_document->create_simple_element( name = 'date' value = string parent = l_element_contract ). * Документы, подтверждающие поставку товаров (работ, услуг), передачу имущественных прав l_element_documents = l_document->create_simple_element( name = 'documents' parent = l_element_contract ). l_element_document = l_document->create_simple_element( name = 'document' parent = l_element_documents ). l_element_docType = l_document->create_simple_element( name = 'docType' parent = l_element_document ). clear string. string = issuance-contractdoct. l_element_code = l_document->create_simple_element( name = 'code' value = string parent = l_element_docType ). clear string. * string = issuance-contractdocdata. concatenate issuance-contractdocdata(4) '-' issuance-contractdocdata+4(2) '-' issuance-contractdocdata+6(2) into string. l_element_date2 = l_document->create_simple_element( name = 'date' value = string parent = l_element_document ). clear string. string = issuance-contractblcode. l_element_blankCode = l_document->create_simple_element( name = 'blankCode' value = string parent = l_element_document ). clear string. string = issuance-contractblseria. l_element_seria = l_document->create_simple_element( name = 'seria' value = string parent = l_element_document ). clear string. string = issuance-contractblnumber. l_element_number2 = l_document->create_simple_element( name = 'number' value = string parent = l_element_document ). * Данные по товарам (работам, услугам), имущественным правам l_element_roster = l_document->create_simple_element( name = 'roster' parent = l_element_issuance ). clear string. string = issuance-totalcostvat. *{ INSERT EGPK900316 19 call function 'CLOI_PUT_SIGN_IN_FRONT' changing value = string. *} INSERT l_rc = l_element_roster->set_attribute( name = 'totalCostVat' value = string ). clear string. string = issuance-totalexcise. *{ INSERT EGPK900316 18 call function 'CLOI_PUT_SIGN_IN_FRONT' changing value = string. *} INSERT l_rc = l_element_roster->set_attribute( name = 'totalExcise' value = string ). clear string. string = issuance-totalvat. *{ INSERT EGPK900316 17 call function 'CLOI_PUT_SIGN_IN_FRONT' changing value = string. *} INSERT l_rc = l_element_roster->set_attribute( name = 'totalVat' value = string ). clear string. string = issuance-totalcost. *{ INSERT EGPK900316 16 call function 'CLOI_PUT_SIGN_IN_FRONT' changing value = string. *} INSERT l_rc = l_element_roster->set_attribute( name = 'totalCost' value = string ). loop at it_vbrp assigning <fs_vbrp> where vbeln = issuance-vbeln. l_element_rosterItem = l_document->create_simple_element( name = 'rosterItem' parent = l_element_roster ). clear string. *{ REPLACE EGPK900316 5 *\ if <fs_vbrp>-posnr = 0. if <fs_vbrp>-uepos = 0. *} REPLACE string = '0'. else. *{ REPLACE EGPK900316 4 *\ write <fs_vbrp>-posnr to str20 no-zero. write <fs_vbrp>-uepos to str20 no-zero. *} REPLACE string = str20. endif. condense string. l_element_number3 = l_document->create_simple_element( name = 'number' value = string parent = l_element_rosterItem ). concatenate <fs_vbrp>-matnr <fs_vbrp>-arktx into string. *{ INSERT EGPK900316 3 string = zcl_sd_item_name_generator=>print_item_name( i_document_number = <fs_vbrp>-vbeln i_position_number = <fs_vbrp>-posnr ). *} INSERT l_element_name4 = l_document->create_simple_element( name = 'name' value = string parent = l_element_rosterItem ). if <fs_vbrp>-kzwi1 = 0 or <fs_vbrp>-kzwi1 = 10. string = <fs_vbrp>-ean11. l_element_code1 = l_document->create_simple_element( name = 'code' value = string parent = l_element_rosterItem ). endif. clear string. select single okei into string from j_3rj_uom_conv where uom = <fs_vbrp>-vrkme. l_element_units = l_document->create_simple_element( name = 'units' value = string parent = l_element_rosterItem ). clear string. string = <fs_vbrp>-fklmg. condense string. *{ INSERT EGPK900316 11 call function 'CLOI_PUT_SIGN_IN_FRONT' changing value = string. *} INSERT l_element_count = l_document->create_simple_element( name = 'count' value = string parent = l_element_rosterItem ). l_element_price = l_document->create_simple_element( name = 'price' value = '0' parent = l_element_rosterItem ). clear string. *{ REPLACE EGPK900316 1 *\ string = <fs_vbrp>-netwr. string = <fs_vbrp>-netwr * <fs_vbrp>-kursk / <fs_vbrp>-volum. write string to str decimals 2. *} REPLACE condense string. *{ INSERT EGPK900316 12 call function 'CLOI_PUT_SIGN_IN_FRONT' changing value = string. *} INSERT l_element_cost = l_document->create_simple_element( name = 'cost' value = string parent = l_element_rosterItem ). l_element_summaExcise = l_document->create_simple_element( name = 'summaExcise' value = '0' parent = l_element_rosterItem ). * НДС l_element_vat = l_document->create_simple_element( name = 'vat' parent = l_element_rosterItem ). string = <fs_vbrp>-kzwi1. *{ INSERT EGPK900316 15 call function 'CLOI_PUT_SIGN_IN_FRONT' changing value = string. *} INSERT l_element_rate = l_document->create_simple_element( name = 'rate' value = string parent = l_element_vat ). if <fs_vbrp>-kzwi1 = 0. string = 'ZERO'. else. string = 'DECIMAL'. endif. l_element_rateType = l_document->create_simple_element( name = 'rateType' value = string parent = l_element_vat ). clear string. string = <fs_vbrp>-kzwi5 * <fs_vbrp>-kursk / <fs_vbrp>-volum. condense string. *{ INSERT EGPK900316 13 call function 'CLOI_PUT_SIGN_IN_FRONT' changing value = string. *} INSERT l_element_summaVat = l_document->create_simple_element( name = 'summaVat' value = string parent = l_element_vat ). clear string. string = <fs_vbrp>-kzwi4 * <fs_vbrp>-kursk / <fs_vbrp>-volum. condense string. *{ INSERT EGPK900316 14 call function 'CLOI_PUT_SIGN_IN_FRONT' changing value = string. *} INSERT l_element_costVat = l_document->create_simple_element( name = 'costVat' value = string parent = l_element_rosterItem ). * Дополнительные сведения * l_element_descriptions = l_document->create_simple_element( name = 'descriptions' parent = l_element_rosterItem ). * l_element_description = l_document->create_simple_element( name = 'description' value = '' parent = l_element_descriptions ). endloop. * Creating a stream factory l_streamfactory = l_ixml->create_stream_factory( ). * Connect internal XML table to stream factory l_ostream = l_streamfactory->create_ostream_itable( table = l_xml_table ). * Rendering the document l_renderer = l_ixml->create_renderer( ostream = l_ostream document = l_document ). l_rc = l_renderer->render( ). * Saving the XML document l_xml_size = l_ostream->get_num_written_raw( ). concatenate patch '\' issuance-znumber '.xml' into string. call method cl_gui_frontend_services=>gui_download exporting bin_filesize = l_xml_size filename = string filetype = 'BIN' changing data_tab = l_xml_table exceptions others = 24. if sy-subrc <> 0. message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. endif. endmethod. method SELECT_PARAMETER. data constname_u type zconstname. constname_u = constname. translate constname_u to upper case. select single value1 from zissuance_cnst into value where constname = constname_u. endmethod. |